Module net/udp

net/udp

Async UDP networking — connectionless datagram sockets.

Types

UdpSocket object
UdpSocket

A UDP socket for sending and receiving datagrams.

Fields

NameTypeDescription
_fdi32
_local_addrSocketAddr
_is_closedbool

Trait Implementations

impl(UdpSocket, ...)
bind : (UdpSocket) fn(addr : SocketAddr, using(io : IO)) -> Impl(Future(UdpSocket, IO, Exception))

Create and bind a UDP socket to the given address.

Parameters

NameTypeNotes
addrSocketAddr

Returns: Impl(Future(UdpSocket, IO, Exception))

send_to : (UdpSocket) fn(self : UdpSocket, data : ArrayList(u8), addr : SocketAddr, using(io : IO)) -> Impl(Future(i32, IO, Exception))

Send a datagram to a specific address. Returns the number of bytes sent.

Parameters

NameTypeNotes
selfUdpSocket
dataArrayList(u8)
addrSocketAddr

Returns: Impl(Future(i32, IO, Exception))

recv : (UdpSocket) fn(self : UdpSocket, buf : *(u8), size : usize, using(io : IO)) -> Impl(Future(i32, IO, Exception))

Receive a datagram into the provided buffer. Returns the number of bytes received.

Parameters

NameTypeNotes
selfUdpSocket
buf*(u8)
sizeusize

Returns: Impl(Future(i32, IO, Exception))

recv_from : (UdpSocket) fn(self : UdpSocket, buf : *(u8), size : usize, src_addr : *(u8), src_addr_len : *(u32), using(io : IO)) -> Impl(Future(i32, IO, Exception))

Receive a datagram and retrieve the sender's address. Returns the number of bytes received.

Parameters

NameTypeNotes
selfUdpSocket
buf*(u8)
sizeusize
src_addr*(u8)
src_addr_len*(u32)

Returns: Impl(Future(i32, IO, Exception))

send : (UdpSocket) fn(self : UdpSocket, data : ArrayList(u8), using(io : IO)) -> Impl(Future(i32, IO, Exception))

Send data on a connected socket (requires prior connect).

Parameters

NameTypeNotes
selfUdpSocket
dataArrayList(u8)

Returns: Impl(Future(i32, IO, Exception))

close : (UdpSocket) fn(self : UdpSocket, using(io : IO)) -> Impl(Future(unit, IO, Exception))

Close the socket.

Parameters

NameTypeNotes
selfUdpSocket

Returns: Impl(Future(unit, IO, Exception))

set_broadcast : (UdpSocket) fn(self : UdpSocket, enabled : bool, using(io : IO)) -> Impl(Future(unit, IO, Exception))

Enable or disable SO_BROADCAST on the socket.

Parameters

NameTypeNotes
selfUdpSocket
enabledbool

Returns: Impl(Future(unit, IO, Exception))

local_addr : (UdpSocket) fn(self : UdpSocket) -> SocketAddr

Get the local address this socket is bound to.

Parameters

NameTypeNotes
selfUdpSocket

Returns: SocketAddr

fd : (UdpSocket) fn(self : UdpSocket) -> i32

Get the underlying file descriptor.

Parameters

NameTypeNotes
selfUdpSocket

Returns: i32

impl(UdpSocket, Dispose(...))
dispose : (fn(self: Self) -> unit)

Returns: unit