xarxa

Crates

git

Versions

default

Flavors

Skip to main content

Module udp

Module udp 

Source
Expand description

UDP sockets.

Stack::add_udp_socket creates a socket inside the stack and returns a UdpHandle identifying it. All operations go through Stack::udp_socket, which borrows the socket as a UdpSocket: receiving only touches the socket state, while sending transmits the datagram immediately.

A single bind call pins down (parts of) the socket’s 4-tuple, local and remote halves at once, each part exact or wildcard. Binding to port 0 allocates an ephemeral port, and binding an identical 4-tuple to another socket’s is rejected.

Received packets are queued with their IP and UDP headers still in the buffer. The addresses returned in UdpMetadata are parsed back out of those header bytes.

UdpMetadata also carries the datagram’s PacketMeta in both directions: on receive it is what the driver attached to the packet, on send it is attached to the packet handed to the driver.

Structs§

RecvPacket
A received UDP datagram.
UdpHandle
A handle to a UDP socket added to a Stack.
UdpMetadata
Metadata for a sent or received UDP datagram.
UdpSocket
A UDP socket borrowed from a Stack, returned by Stack::udp_socket.
UdpSocketIter
Iterator over the UDP sockets of a Stack, returned by Stack::udp_sockets.

Enums§

BindError
Error returned by UdpSocket::bind.
RecvError
Error returned by UdpSocket::recv and the peek methods.
SendError
Error returned by UdpSocket::send_slice and UdpSocket::send_with.