net::udp +linux +x86_64

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 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[link]

type connect_option = net::sockflags;

Options for connect.

type listen_option[link]

type listen_option = (portassignment | net::sockflags);

Options available for listen.

type portassignment[link]

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[link]

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[link]

fn listen(
	addr: ip::addr,
	port: u16,
	options: listen_option...
) (net::socket | net::error);

Creates a UDP socket bound to an interface.

fn recvfrom[link]

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[link]

fn send(sock: net::socket, buf: []u8) (size | net::error);

Sends a UDP packet to the destination previously specified by connect.

fn sendto[link]

fn sendto(
	sock: net::socket,
	buf: []u8,
	dest: ip::addr,
	port: u16,
) (size | net::error);

Sends a UDP packet using this socket.