1
0
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:
Calvin Rose
2020-11-08 10:38:28 -06:00
parent 1092013c2b
commit 07910272e2
4 changed files with 154 additions and 23 deletions

14
examples/echoserve.janet Normal file
View 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)