Effect Udppub

Source
:effect(pub) Udp
  .udp-bind ( Str AnyInt → (Result AnyUInt Str) )
  .udp-connect ( Str AnyInt AnyUInt → (Result AnyUInt Str) )
  .udp-send-to ( Bytes Str AnyInt AnyUInt → (Result AnyUInt Str) )
  .udp-send ( Bytes AnyUInt → (Result AnyUInt Str) )
  .udp-recv-from ( AnyUInt AnyUInt → (Result (Pair Bytes (Pair Str AnyInt)) Str) )
  .udp-recv ( AnyUInt AnyUInt → (Result Bytes Str) )
  .udp-close ( AnyUInt → )
  .udp-local-addr ( AnyUInt → (Pair Str AnyInt) )
  .udp-set-broadcast ( Bool AnyUInt → (Result Unit Str) )
Description

UDP datagram effect. Socket handles are carried as AnyUInt fds; SocketAddr is represented as a (Pair Str AnyInt) of (host, port).

Parent chain:IO → Net → Udp

Operations

.udp-bind ( Str AnyInt → (Result AnyUInt Str) )

Bind a UDP socket to the given host:port. Returns a socket handle.

.udp-connect ( Str AnyInt AnyUInt → (Result AnyUInt Str) )

Pin the socket's default peer to the given host:port.

.udp-send-to ( Bytes Str AnyInt AnyUInt → (Result AnyUInt Str) )

Send a single datagram to the given host:port via the socket.

.udp-send ( Bytes AnyUInt → (Result AnyUInt Str) )

Send a datagram to the socket's connected peer.

.udp-recv-from ( AnyUInt AnyUInt → (Result (Pair Bytes (Pair Str AnyInt)) Str) )

Receive a datagram (bytes + sender host:port) up to max bytes.

.udp-recv ( AnyUInt AnyUInt → (Result Bytes Str) )

Receive a datagram from the connected peer up to max bytes.

.udp-close ( AnyUInt → )

Close the socket, releasing its kernel resources.

.udp-local-addr ( AnyUInt → (Pair Str AnyInt) )

Return the local host:port the socket is bound to.

.udp-set-broadcast ( Bool AnyUInt → (Result Unit Str) )

Enable or disable SO_BROADCAST on the socket.