net::udp
Index
Types
type connect_option;
type listen_option;
type portassignment;
Functions
fn connect(ip::addr, u16, connect_option...) (net::socket | net::error);
fn listen(ip::addr, u16, listen_option...) (net::socket | net::error);
fn recv(net::socket, []u8) (size | net::error);
fn recvfrom(net::socket, []u8, nullable *ip::addr, nullable *u16) (size | net::error);
fn send(net::socket, []u8) (size | net::error);
fn sendto(net::socket, []u8, ip::addr, u16) (size | net::error);
Types
type connect_option
type connect_option = net::sockflags;
Options for connect.
type listen_option
type listen_option = (portassignment | net::sockflags);
Options available for listen.
type portassignment
type portassignment = *u16;
To have the system select an arbitrary unused port for listen, set port to
zero. To retrieve the assigned port, provide this as one of the options and
the addressed u16 will be filled in with the port.
Functions
fn connect
fn connect(
dest: ip::addr,
port: u16,
options: connect_option...
) (net::socket | net::error);
Creates a UDP socket and sets the default destination to the given address.
fn listen
fn listen(
addr: ip::addr,
port: u16,
options: listen_option...
) (net::socket | net::error);
Creates a UDP socket bound to an interface.
fn recv
fn recv(sock: net::socket, buf: []u8) (size | net::error);
Receives a UDP packet from a connected UDP socket.
fn recvfrom
fn recvfrom(
sock: net::socket,
buf: []u8,
src: nullable *ip::addr,
port: nullable *u16,
) (size | net::error);
Receives a UDP packet from a bound socket.
fn send
fn send(sock: net::socket, buf: []u8) (size | net::error);
Sends a UDP packet to a connected UDP socket.
fn sendto
fn sendto(
sock: net::socket,
buf: []u8,
dest: ip::addr,
port: u16,
) (size | net::error);
Sends a UDP packet using this socket.