UdpSocket

bind

defn

(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).

close

external

(Fn [UdpSocket] ())

closes the UDP socket.

copy

external

(Fn [(Ref UdpSocket a)] UdpSocket)

poll-fd

defn

(Fn [(Ref UdpSocket a)] Int)

                        (poll-fd s)
                    

recv-from

defn

(Fn [(Ref UdpSocket a)] (Result (Pair (Array Byte) String) String))

                        (recv-from sock)
                    

receives data 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

defn

(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.

set-timeout

external

(Fn [(Ref UdpSocket a), Int] ())

sets read and write timeouts in seconds.