1
0
mirror of https://github.com/janet-lang/janet synced 2024-12-29 18:00:26 +00:00
janet/examples/echoserve.janet

16 lines
359 B
Clojure
Raw Normal View History

(defn handler
"Simple handler for connections."
[stream]
(defer (:close stream)
(def id (gensym))
(def b @"")
(print "Connection " id "!")
(while (:read stream 1024 b)
(printf " %v -> %v" id b)
(:write stream b)
(buffer/clear b))
(printf "Done %v!" id)
(ev/sleep 0.5)))
(net/server "127.0.0.1" "8000" handler)