Skip to main content

Module socket

Module socket 

Source
Expand description

Unix domain socket primitives.

This module exposes Linux/Android AF_UNIX stream socket mechanics only: bind, listen, accept, connect, chmod for filesystem sockets, peer credentials, and byte I/O through Fd. Callers own all protocol, message framing, authentication policy, daemon behavior, and socket naming.

Abstract socket names are Linux/Android-only. They are encoded with a leading NUL byte in sun_path; interior NUL bytes in the caller-provided abstract name are preserved because the kernel uses the explicit sockaddr length, not C string termination.

Structs§

PeerCred
Peer process credentials when the platform exposes them.
UnixListener
Owned non-blocking Unix listener descriptor.
UnixSocketBindOptions
Bind options for a Unix stream listener.
UnixStream
Owned non-blocking Unix stream descriptor.

Enums§

StaleSocketPolicy
Explicit stale pathname behavior for filesystem socket binds.
UnixConnectResult
Result of starting a non-blocking Unix stream connection.
UnixSocketAddr
Unix socket address.

Functions§

bind
Bind a new Unix domain stream listener.
chmod
Change mode bits on a Unix socket filesystem path.
chmod_path
Change mode bits on a Unix socket filesystem path.
connect
Connect a non-blocking Unix stream socket.
connect_named
Like connect but binds the client socket to local before connecting, so the peer name appears in /proc/net/unix with an identifiable label.
socketpair
Create a paired, non-blocking connected Unix stream socket set.