Module interprocess::local_socket

source ·
Expand description

Local sockets, an IPC primitive featuring a server and multiple clients connecting to that server using a filesystem path 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§

Modules§

  • 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.
  • tokiotokio
    Asynchronous local sockets which work with the Tokio runtime and event loop.
  • Traits representing the interface of local sockets.

Structs§

Enums§

  • Consistent platform-specific mapping from filesystem paths to local socket names.
  • Consistent platform-specific mapping from arbitrary OS strings to local socket names.
  • Local socket server, listening for connections.
  • Receive half of a local socket stream, obtained by splitting a Stream.
  • Send half of a local socket stream, obtained by splitting a Stream.
  • Local socket byte stream, obtained either from Listener or by connecting to an existing local socket.

Traits§

Type Aliases§