baml.net.UdpSocket

A UDP socket. Created by `baml.net.UdpSocket.bind`. UDP is connectionless and message-oriented: every `send_to` / `recv_from` carries a single datagram.

Reference version

Signature

class baml.net.UdpSocket

A UDP socket. Created by baml.net.UdpSocket.bind. UDP is connectionless and message-oriented: every send_to / recv_from carries a single datagram.

Source:<builtin>/baml/ns_net/net.bamlbytes 29914878

Fields

_handle

$rust_type

(internal)

Static methods

function

bind

(addr: string) -> baml.net.UdpSocket throws baml.errors.Io

Binds to addr (e.g. "0.0.0.0:0" for an OS-assigned ephemeral port) and returns the socket.

Instance methods

function

recv_from

(
self,
timeout: baml.time.Duration | null = …

Receives a single datagram, returning its payload bytes together with the address of the sender.

timeout bounds the wait for a datagram; null (the default) blocks indefinitely. On expiry this throws baml.errors.Timeout and the socket remains usable. Mirrors UdpSocket::set_read_timeout.

function

send_to

(
self,
data: uint8array,
addr: string,
timeout: baml.time.Duration | null = …

Sends data as a single datagram to addr. Returns the number of bytes sent.

timeout bounds the send; null (the default) blocks indefinitely. On expiry this throws baml.errors.Timeout. Mirrors UdpSocket::set_write_timeout.

Implementations

baml.Concrete for T

Source:<builtin>/baml/core.bamlbytes 747779