JanetDocsI'm feeling luckyGithub sign in



    (net/read stream nbytes &opt buf)
    Read up to n bytes from a stream, suspending the current fiber until
    the bytes are available. If less than n bytes are available (and more
    than 0), will push those bytes and return early. Returns a buffer with
    up to n more bytes in it.

1 exampleSign in to add an example
# in a terminal:
# $ while true; do date | nc 1234 -w 1; sleep 1; done

# in a janet repl:
(net/server "" 1234
  (fn [conn]
    (prin (net/read conn 4096))
    (net/close conn)))
# note: output doesn't actually start until you (quit) your repl's fiber: