Expand description
Local sockets, an IPC primitive featuring a server and multiple clients connecting to that server using a filesystem path or an identifier inside a special namespace, each having a private connection to that server.
§Implementation types
Local sockets are not a real IPC method implemented by the OS – they exist to paper over the differences between the two underlying implementations currently in use: Unix domain sockets and Windows named pipes.
Interprocess defines traits that implementations of local sockets implement, and enums that
constitute devirtualized trait objects (not unlike those provided by the enum_dispatch
crate)
for those traits. The implementation used, in cases where multiple options apply, is chosen at
construction via the name and name type infrastructure.
§Differences from regular sockets
A few missing features, primarily on Windows, require local sockets to omit some important functionality, because code relying on it wouldn’t be portable. Some notable differences are:
- No
.shutdown()
– your communication protocol must manually negotiate end of transmission. Notably,.read_to_string()
and.read_all()
will always block indefinitely at some point. - No datagram sockets – the difference in semantics between connectionless datagram Unix-domain sockets and connection-based named message pipes on Windows does not allow bridging those two into a common API. You can emulate datagrams on top of streams anyway, so no big deal, right?
Re-exports§
pub use traits::ListenerNonblockingMode;
Modules§
- prelude
- Re-exports of traits done in a way that doesn’t pollute the scope, as well as of the
enum-dispatch types with their names prefixed with
LocalSocket
. - tokio
tokio
- Asynchronous local sockets which work with the Tokio runtime and event loop.
- traits
- Traits representing the interface of local sockets.
Structs§
- Incoming
- An infinite iterator over incoming client connections of a
Listener
. - Listener
Options - A builder for local socket listeners, including
Listener
. - Name
- Name for a local socket.
Enums§
- Generic
File Path - Consistent platform-specific mapping from filesystem paths to local socket names.
- Generic
Namespaced - Consistent platform-specific mapping from arbitrary OS strings to local socket names.
- Listener
- Local socket server, listening for connections.
- Recv
Half - Receive half of a local socket stream, obtained by splitting a
Stream
. - Send
Half - Send half of a local socket stream, obtained by splitting a
Stream
. - Stream
- Local socket byte stream, obtained either from
Listener
or by connecting to an existing local socket.
Traits§
- Name
Type - Mappings from string types to local socket names.
- Namespaced
Name Type - Mappings from strings to local socket names.
- Path
Name Type - Mappings from paths to local socket names.
- ToFs
Name - Conversion to a filesystem path-type local socket name.
- ToNs
Name - Conversion to a namespaced local socket name.
Type Aliases§
- Reunite
Error ReuniteError
forStream
.- Reunite
Result - Result type for
.reunite()
onStream
.