Module udsocket

Source
Available on Unix only.
Expand description

Support for Unix domain sockets, abbreviated here as “Ud-sockets”.

Ud-sockets are a special kind of sockets which work in the scope of only one system and use file paths instead of IPv4/IPv6 addresses and 16-bit socket numbers. Aside from their high reliability and convenience for the purposes of IPC (such as filesystem-level privelege management and the similarity to named pipes), they have a unique feature which cannot be replaced by any other form of IPC: ancillary data.

§Ancillary data

Thanks to this feature, Ud-sockets can transfer ownership of a file descriptor to another process, even if it doesn’t have a parent-child relationship with the file descriptor owner and thus does not inherit anything via fork(). Aside from that, ancillary data can contain credentials of a process, which are validated by the kernel unless the sender is the superuser, meaning that this way of retrieving credentials can be used for authentification.

§Usage

The UdStreamListener and UdSocket types are two starting points, depending on whether you intend to use UDP-like datagrams or TCP-like byte streams.

Modules§

tokiotokio_support
Asynchronous Ud-sockets which work with the Tokio runtime and event loop.

Structs§

AncillaryDataDecoder
An iterator which decodes ancillary data from an ancillary data buffer.
EncodedAncillaryData
A buffer used for sending ancillary data into Unix domain sockets.
Incoming
An infinite iterator over incoming client connections of a UdStreamListener.
UdSocket
A datagram socket in the Unix domain.
UdStream
A Unix domain socket byte stream, obtained either from UdStreamListener or by connecting to an existing server.
UdStreamListener
A Unix domain byte stream socket server, listening for connections.

Enums§

AncillaryData
Ancillary data to be sent through a Unix domain socket or read from an input buffer.
AncillaryDataBuf
A buffer used for receiving ancillary data from Unix domain sockets.
UdSocketPath
Represents a name for a Unix domain socket.

Constants§

MAX_UDSOCKET_PATH_LEN
The maximum path length for Unix domain sockets. UdStreamListener::bind panics if the specified path exceeds this value.

Traits§

ToUdSocketPath
Trait for types which can be converted to a path to a Unix domain socket.