UdpSocket
bind
(Fn [(Ref String a), Int] (Result UdpSocket String))
(bind addr port)
binds a UDP socket to the given address and port.
Returns (Result UdpSocket String).
local-port
(Fn [(Ref UdpSocket a)] Int)
returns the port the socket is bound to. Useful
after binding to port 0 to discover the OS-assigned port.
recv-from
(Fn [(Ref UdpSocket a)] (Result (Pair (Array Byte) String) String))
(recv-from sock)
receives a datagram and the sender's address.
Returns (Result (Pair (Array Byte) String) String) where the string is
the sender's address in ip:port format.
send-to
(Fn [(Ref UdpSocket a), (Ref String b), Int, (Ref (Array Byte) c)] (Result Int String))
(send-to sock host port data)
sends data to a remote address. Returns bytes sent or an error.