net::unix +linux +x86_64

net::unix provides access to Unix sockets for networking.

A protocol provider for net::dial is provided by this module, but you must import net::unix at least once in order for it to be visible to net::dial.



type addr;
type backlog;
type connect_option;
type listen_option;


type invalid;


fn accept(net::socket, net::sockflags...) (net::socket | net::error);
fn addfiles(*net::msghdr, io::file...) void;
fn allocfiles(*net::msghdr, size) void;
fn connect(addr, connect_option...) (net::socket | net::error);
fn listen(addr, listen_option...) (net::socket | net::error);
fn recvfiles(*net::msghdr, size) []io::file;
fn socketpair(net::sockflags...) ((net::socket, net::socket) | net::error);


type addr[link]

type addr = str;

A UNIX socket address.

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 = net::sockflags;

Options for connect.

type listen_option[link]

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

Options for listen.


type invalid[link]

type invalid = !void;

Invalid UNIX socket path.


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

fn addfiles(buf: *net::msghdr, files: io::file...) void;

Adds a list of file descriptors to the ancillary data for a sendmsg operation.

fn allocfiles[link]

fn allocfiles(buf: *net::msghdr, nfile: size) void;

Prepares an ancillary data buffer to receive files during a recvmsg operation.

fn connect[link]

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

Opens a UNIX socket connection to the path. Blocks until the connection is established.

fn listen[link]

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

Binds a UNIX socket to the given path.

fn recvfiles[link]

fn recvfiles(buf: *net::msghdr, nfile: size) []io::file;

Receives files from an ancillary data buffer which was previously prepared with allocfiles.

fn socketpair[link]

fn socketpair(flags: net::sockflags...) ((net::socket, net::socket) | net::error);

A thin wrapper around socketpair(2) that presumes rt::AF_UNIX for the domain and returns an unnamed pair of sockets of type rt::SOCK_STREAM.