mirror of
https://github.com/janet-lang/janet
synced 2025-09-08 13:56:09 +00:00
Get socket reads and writes working with IOCP.
This commit is contained in:
14
examples/echoserve.janet
Normal file
14
examples/echoserve.janet
Normal file
@@ -0,0 +1,14 @@
|
||||
(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)))
|
||||
|
||||
(net/server "127.0.0.1" "8000" handler)
|
Reference in New Issue
Block a user