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§
- Recv
Packet - 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 byStack::udp_socket. - UdpSocket
Iter - Iterator over the UDP sockets of a
Stack, returned byStack::udp_sockets.
Enums§
- Bind
Error - Error returned by
UdpSocket::bind. - Recv
Error - Error returned by
UdpSocket::recvand the peek methods. - Send
Error - Error returned by
UdpSocket::send_sliceandUdpSocket::send_with.