mirror of
https://github.com/janet-lang/janet
synced 2024-11-25 17:57:17 +00:00
14 lines
295 B
Plaintext
14 lines
295 B
Plaintext
|
(defn handler
|
||
|
"Simple handler for connections."
|
||
|
[stream]
|
||
|
(def id (gensym))
|
||
|
(def b @"")
|
||
|
(print "Connection " id "!")
|
||
|
(while (net/read stream 1024 b)
|
||
|
(net/write stream b)
|
||
|
(buffer/clear b))
|
||
|
(printf "Done %v!" id)
|
||
|
(net/close stream))
|
||
|
|
||
|
(net/server "127.0.0.1" "8000" handler)
|