net::udp+x86_64 +linux

Index

Types

type connect_option = net::sockflag;
type listen_option = (reuseport | reuseaddr | portassignment | net::sockflag);
type portassignment = *u16;
type reuseaddr = void;
type reuseport = void;

Functions

fn connect(dest: ip::addr, port: u16, options: connect_option...) (net::socket | net::error);
fn listen(addr: ip::addr, port: u16, options: listen_option...) (net::socket | net::error);
fn recv(sock: net::socket, buf: []u8) (size | net::error);
fn recvfrom(sock: net::socket, buf: []u8, src: nullable *ip::addr, port: nullable *u16) (size | net::error);
fn send(sock: net::socket, buf: []u8) (size | net::error);
fn sendto(sock: net::socket, buf: []u8, dest: ip::addr, port: 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.