socket
A networking library for Carp with TCP, UDP, Unix domain sockets, buffered I/O, and I/O multiplexing.
All fallible operations return (Result T String).
TCP
(match (TcpListener.bind "0.0.0.0" 8080)
(Result.Success listener)
(do
(TcpListener.while-accept &listener client
(ignore (TcpStream.send &client "hello\n")))
(TcpListener.close listener))
(Result.Error e) (IO.errorln &e))
I/O Multiplexing
(match (Poll.create)
(Result.Success poll)
(do (ignore (Poll.add-read &poll &listener))
(match (Poll.wait &poll 1000)
(Result.Success events) (println* (Array.length &events) " events")
_ ())
(Poll.close poll))
_ ())