net::unix
unix: Unix domain sockets support
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.
Index
Types
type addr;
type backlog;
type connect_option;
type listen_option;
Errors
type invalid;
Functions
fn accept(sock: net::socket, flags: net::sockflag = 0) (net::socket | net::error);
fn addfiles(buf: *net::msghdr, files: io::file...) (void | nomem);
fn allocfiles(buf: *net::msghdr, nfile: size) (void | nomem);
fn connect(addr: addr, options: connect_option...) (net::socket | net::error);
fn listen(addr: addr, options: listen_option...) (net::socket | net::error);
fn recvfiles(buf: *net::msghdr, nfile: size) []io::file;
fn socketpair(flags: net::sockflag = 0) ((net::socket, net::socket) | net::error);
Types
type addr
type addr = str;
A UNIX socket address.
type backlog
type backlog = u32;
Configures the backlog size for a listener. If not specified, a sensible default (10) is used.
type connect_option
type connect_option = net::sockflag;
Options for connect.
type listen_option
type listen_option = (backlog | net::sockflag);
Options for listen.
Errors
type invalid
type invalid = !void;
Invalid UNIX socket path.
Functions
fn accept
fn accept(sock: net::socket, flags: net::sockflag = 0) (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 allocfiles
fn allocfiles(buf: *net::msghdr, nfile: size) (void | nomem);
Prepares a buffer in which to store file descriptors received from a call to net::recvmsg over a Unix socket. One must call allocfiles prior to calling net::recvmsg to prepare this buffer, then use recvfiles to extract io::file handles from the buffer after the message is received.
This function concerns receiving files, see addfiles for information about sending files.
fn connect
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
fn listen(addr: addr, options: listen_option...) (net::socket | net::error);
Binds a UNIX socket to the given path.
fn recvfiles
fn recvfiles(buf: *net::msghdr, nfile: size) []io::file;
Receives files from a control message which was previously prepared with allocfiles.
fn socketpair
fn socketpair(flags: net::sockflag = 0) ((net::socket, net::socket) | net::error);
A thin wrapper around socketpair(2) that presumes sys::AF_UNIX for the domain and returns an unnamed pair of sockets of type sys::SOCK_STREAM.