source
structure Std.Internal.IO.Async.UDP.Socket :
Type

Represents a UDP socket.

- ofNative :: (

- native : UV.UDP.Socket

- )

Instances For

source
inductive Std.Internal.IO.Async.UDP.Membership :
Type

Membership type for multicast operations.

- leaveGroup : Membership
- enterGroup : Membership

Instances For

source
@[inline]
def Std.Internal.IO.Async.UDP.Socket.mk :
IO Socket

Creates a new UDP socket.

Equations

- Std.Internal.IO.Async.UDP.Socket.mk = do let native ← Std.Internal.UV.UDP.Socket.new pure { native := native }

Instances For

source
@[inline]
def Std.Internal.IO.Async.UDP.Socket.bind (s : Socket) (addr : Net.SocketAddress) :
IO Unit

Binds the UDP socket to the given address. Address reuse is enabled to allow rebinding the same address.

Equations

- s.bind addr = s.native.bind addr

Instances For

source
@[inline]
def Std.Internal.IO.Async.UDP.Socket.connect (s : Socket) (addr : Net.SocketAddress) :
IO Unit

Associates the UDP socket with the given address and port, so every message sent by this socket is automatically sent to that destination.

Equations

- s.connect addr = s.native.connect addr

Instances For

source
@[inline]
def Std.Internal.IO.Async.UDP.Socket.sendAll (s : Socket) (data : Array ByteArray) (addr : Option Net.SocketAddress := none) :
Async Unit

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

Equations

- s.sendAll data addr = Std.Internal.IO.Async.Async.ofPromise (s.native.send data addr)

Instances For

source
@[inline]
def Std.Internal.IO.Async.UDP.Socket.send (s : Socket) (data : ByteArray) (addr : Option Net.SocketAddress := none) :
Async Unit

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

Equations

- s.send data addr = Std.Internal.IO.Async.Async.ofPromise (s.native.send #[data] addr)

Instances For

source
@[inline]
def Std.Internal.IO.Async.UDP.Socket.recv (s : Socket) (size : UInt64) :
Async (ByteArray × Option Net.SocketAddress)

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.

Equations

- s.recv size = Std.Internal.IO.Async.Async.ofPromise (s.native.recv size)

Instances For

source
def Std.Internal.IO.Async.UDP.Socket.recvSelector (s : Socket) (size : UInt64) :
Selector (ByteArray × Option Net.SocketAddress)

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

Equations

- One or more equations did not get rendered due to their size.

Instances For

source
@[inline]
def Std.Internal.IO.Async.UDP.Socket.getSockName (s : Socket) :
IO Net.SocketAddress

Gets the local address of the UDP socket.

Equations

- s.getSockName = s.native.getSockName

Instances For

source
@[inline]
def Std.Internal.IO.Async.UDP.Socket.getPeerName (s : Socket) :
IO Net.SocketAddress

Gets the remote address of the UDP socket. On unconnected handles, it throws the `.invalidArgument`. error.

Equations

- s.getPeerName = s.native.getPeerName

Instances For

source
@[inline]
def Std.Internal.IO.Async.UDP.Socket.setBroadcast (s : Socket) (enable : Bool) :
IO Unit

Enables or disables broadcasting for the UDP socket.

Equations

- s.setBroadcast enable = s.native.setBroadcast enable

Instances For

source
@[inline]
def Std.Internal.IO.Async.UDP.Socket.setMulticastLoop (s : Socket) (enable : Bool) :
IO Unit

Enables or disables multicast loopback for the UDP socket.

Equations

- s.setMulticastLoop enable = s.native.setMulticastLoop enable

Instances For

source
@[inline]
def Std.Internal.IO.Async.UDP.Socket.setMulticastTTL (s : Socket) (ttl : UInt32) :
IO Unit

Sets the time-to-live (TTL) for multicast packets.

Equations

- s.setMulticastTTL ttl = s.native.setMulticastTTL ttl

Instances For

source
@[inline]
def Std.Internal.IO.Async.UDP.Socket.setMembership (s : Socket) (multicastAddr : Net.IPAddr) (interfaceAddr : Option Net.IPAddr) (membership : Membership) :
IO Unit

Sets the membership for joining or leaving a multicast group.

Equations

- s.setMembership multicastAddr interfaceAddr Std.Internal.IO.Async.UDP.Membership.leaveGroup = s.native.setMembership multicastAddr interfaceAddr 0
- s.setMembership multicastAddr interfaceAddr Std.Internal.IO.Async.UDP.Membership.enterGroup = s.native.setMembership multicastAddr interfaceAddr 1

Instances For

source
@[inline]
def Std.Internal.IO.Async.UDP.Socket.setMulticastInterface (s : Socket) (interfaceAddr : Net.IPAddr) :
IO Unit

Sets the multicast interface for sending packets.

Equations

- s.setMulticastInterface interfaceAddr = s.native.setMulticastInterface interfaceAddr

Instances For

source
@[inline]
def Std.Internal.IO.Async.UDP.Socket.setTTL (s : Socket) (ttl : UInt32) :
IO Unit

Sets the TTL for outgoing packets.

Equations

- s.setTTL ttl = s.native.setTTL ttl

Instances For