1
0
mirror of https://github.com/janet-lang/janet synced 2025-10-11 22:07:43 +00:00

Improve reading and writing from streams.

Handle errors earlier, and allow 0 length packets from UDP
but not from TCP. This should more closely follow the exact specs
of send and recv calls.
This commit is contained in:
Calvin Rose
2020-11-02 09:05:19 -06:00
parent 8942e348bd
commit 4d21b582c7
2 changed files with 30 additions and 19 deletions

View File

@@ -6,7 +6,7 @@
(def b @"")
(print "Connection " id "!")
(while (:read stream 1024 b)
(repeat 10 (print "work for " id " ...") (ev/sleep 1))
(repeat 10 (print "work for " id " ...") (ev/sleep 0.1))
(:write stream b)
(buffer/clear b))
(printf "Done %v!" id)))