socketplate.address

Parsing of all kind of socket addresses

Currently supported

  • Unix Domain Socket path (e.g. /var/run/myapp.sock)
  • IPv4 address (e.g. 192.168.0.1)
  • IPv4 address with port (e.g. 192.168.0.1:1234)
  • IPv6 address (e.g. [2001:0db8::1])
  • IPv6 address with port (e.g. [2001:0db8::1]:1234)

Rules

  • Unix Domain socket paths MUST be absolute (i.e. start with /) to prevent ambiguity.
  • IPv4 resp. IPv6 addresses are separated from their (optional) accompanying port number by :.
  • IPv6 addresses MUST be encapsulated in square brackets ([…]). (This prevents ambiguity with regard to the address/port separator :.)

Idea

Socket addresses are intended to provide a concise way to describe the “address” of network socket.

The original use case was to provide a simple way to describe listening sockets in a uniform way. For a command line interface there should only be a single --socket=<address> parameter, regardless of whether the specified address is IPv4 or IPv6 – or even a Unix Domain Socket path.

Relation to URIs

While similarly looking, socket addresses neither are URIs nor to be considered a part/subset of them.

For example, in comparison to URIs there’s no protocol scheme or path. Also there are no domain names in socket addresses (thus no DNS resolution necessary or provided).

Members

Functions

makeSocketAddress
SocketAddress makeSocketAddress(string address, ushort port)
makeSocketAddress
SocketAddress makeSocketAddress(string unixDomainSocketPath)
parseSocketAddress
bool parseSocketAddress(string input, SocketAddress result)

Socket address triage and parsing function

Structs

SocketAddress
struct SocketAddress
Undocumented in source.

Meta