net::tcp+x86_64 +linux

Index

Types

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

Functions

fn accept(sock: net::socket, flags: net::sockflag...) (net::socket | net::error);
fn connect(addr: 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 peeraddr(peer: net::socket) ((ip::addr, u16) | void);

Types

type backlog[link]

type backlog = u32;

Configures the backlog size for a listener. If not specified, a sensible default (10) is used.

type connect_option[link]

type connect_option = (keepalive | net::sockflag);

Options for connect.

type keepalive[link]

type keepalive = void;

Enables keep-alive for a socket.

type listen_option[link]

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

Options 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 TCP listener.

type reuseport[link]

type reuseport = void;

Enables port re-use for a TCP listener.

Functions

fn accept[link]

fn accept(sock: net::socket, flags: net::sockflag...) (net::socket | net::error);

Accepts the next connection from a socket. Blocks until a new connection is available. This is a convenience wrapper around net::accept.

fn connect[link]

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

Opens a TCP connection to the given host and port. Blocks until the connection is established.

fn listen[link]

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

Binds a TCP socket to the given address.

fn peeraddr[link]

fn peeraddr(peer: net::socket) ((ip::addr, u16) | void);

Returns the remote address for a given connection, or void if none is available.