Membership type for multicast operations.
- leaveGroup : Membership
- enterGroup : Membership
Instances For
Creates a new UDP socket.
Equations
- Std.Async.UDP.Socket.mk = do let native ← Std.Internal.UV.UDP.Socket.new pure { native := native }
Instances For
Binds the UDP socket to the given address. Address reuse is enabled to allow rebinding the same address.
Instances For
Associates the UDP socket with the given address and port, so every message sent by this socket is automatically sent to that destination.
Instances For
Sends multiple data buffers through an UDP socket. The addr parameter specifies the destination
address. If addr is none, the data is sent to the default peer address set by connect.
Throws an IO.Error.invalidArgument if a buffer is 4 GiB or larger.
Equations
- s.sendAll data addr = Std.Async.Async.ofPromise (s.native.send data addr)
Instances For
Sends data through an UDP socket. The addr parameter specifies the destination address. If addr
is none, the data is sent to the default peer address set by connect. Throws an
IO.Error.invalidArgument if data is 4 GiB or larger.
Instances For
Receives data from an UDP socket. size is for the maximum bytes to receive.
The promise resolves when some data is available or an error occurs. If the socket
has not been previously bound with bind, it is automatically bound to 0.0.0.0
(all interfaces) with a random port.
Furthermore calling this function in parallel with recvSelector is not supported.
A datagram larger than size is discarded in its entirety, and this throws an
IO.Error.resourceExhausted instead of returning a truncated prefix. The socket stays usable, so a
receive loop should catch the error per datagram.
Throws an IO.Error.invalidArgument if size is 0 or at least 4 GiB.
Equations
- s.recv size = Std.Async.Async.ofPromise (s.native.recv size)
Instances For
Creates a Selector that resolves once s has data available, up to at most size bytes,
and provides that data. If the socket has not been previously bound with bind, it is
automatically bound to 0.0.0.0 (all interfaces) with a random port.
Calling this function does starts the data wait, only when it's used with Selectable.one or combine.
It must not be called in parallel with recv.
Fails with an IO.Error.resourceExhausted if the datagram is larger than size, and with an
IO.Error.invalidArgument if size is 0 or at least 4 GiB, like recv.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Gets the local address of the UDP socket.
Equations
Instances For
Gets the remote address of the UDP socket. On unconnected handles, it throws the .invalidArgument.
error.
Equations
Instances For
Enables or disables broadcasting for the UDP socket.
Equations
- s.setBroadcast enable = s.native.setBroadcast enable
Instances For
Enables or disables multicast loopback for the UDP socket.
Equations
- s.setMulticastLoop enable = s.native.setMulticastLoop enable
Instances For
Sets the time-to-live (TTL) for multicast packets.
Equations
- s.setMulticastTTL ttl = s.native.setMulticastTTL ttl
Instances For
Sets the membership for joining or leaving a multicast group.
Equations
- s.setMembership multicastAddr interfaceAddr Std.Async.UDP.Membership.leaveGroup = have membership := 0; s.native.setMembership multicastAddr interfaceAddr membership
- s.setMembership multicastAddr interfaceAddr Std.Async.UDP.Membership.enterGroup = have membership := 1; s.native.setMembership multicastAddr interfaceAddr membership
Instances For
Sets the multicast interface for sending packets.
Equations
- s.setMulticastInterface interfaceAddr = s.native.setMulticastInterface interfaceAddr