net::udp+x86_64 +linux

Index

Types

type connect_option;
type listen_option;
type portassignment;
type reuseaddr;
type reuseport;

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

type connect_option = net::sockflag;

Options for connect.

type listen_option[link]

type listen_option = (reuseport | reuseaddr | portassignment | net::sockflag);

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.

type reuseaddr[link]

type reuseaddr = void;

Enables address re-use for a UDP listener.

type reuseport[link]

type reuseport = void;

Enables port re-use for a UDP listener.

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

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

Receives a UDP packet from a connected UDP socket.

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 a connected UDP socket.

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.