net::tcp +linux +x86_64



type backlog;
type connect_option;
type keepalive;
type listen_option;
type portassignment;
type reuseaddr;
type reuseport;


fn accept(net::socket, net::sockflags...) (net::socket | net::error);
fn connect(ip::addr, u16, connect_option...) (net::socket | net::error);
fn listen(ip::addr, u16, listen_option...) (net::socket | net::error);
fn peeraddr(net::socket) ((ip::addr, u16) | void);


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::sockflags);

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::sockflags);

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.


fn accept[link]

fn accept(
	sock: net::socket,
	flags: net::sockflags...
) (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.