TcpListener
accept
(Fn [(Ref TcpListener a)] (Result TcpStream String))
(accept listener)
accepts a new TCP connection, returning a TcpStream.
Blocks until a client connects. Returns (Result TcpStream String).
bind
(Fn [(Ref String a), Int] (Result TcpListener String))
(bind addr port)
binds a TCP listener to the given address and port.
The socket is set to reuse address/port and starts listening immediately.
Returns (Result TcpListener String).
local-address
(Fn [(Ref TcpListener a)] String)
returns the IP address the listener is bound to.
local-port
(Fn [(Ref TcpListener a)] Int)
returns the port the listener is bound to. Useful when binding to port 0 (OS-assigned).
set-reuseaddr
(Fn [(Ref TcpListener a), Int] ())
enables or disables SO_REUSEADDR on the listener.
while-accept
Macro
(while-accept listener name :rest forms)
accepts connections in a loop. Binds each accepted stream
to name and executes forms, then closes the stream. Loops forever.