Skip to main content

Module listener

Module listener 

Source
Expand description

Helpers for the listening sockets of the server: private sockets, socket paths of any length and the errors of the accept loops.

Structsยง

AcceptErrors ๐Ÿ”’
The failed accepts of a listener which keeps going.
SocketInUse ๐Ÿ”’
A socket which a running process still serves, so it must not be replaced. A type of its own tells it apart from other errors, like for the tests, which retry while a process they forked holds a socket.

Constantsยง

ACCEPT_BACKOFF ๐Ÿ”’
How long an accept loop pauses after a failed accept.
ACCEPT_ERROR_INTERVAL ๐Ÿ”’
How often the failed accepts of a listener get logged as errors, a server out of descriptors would log one every ACCEPT_BACKOFF otherwise.

Functionsยง

bind_long_path ๐Ÿ”’
Bind a listener with bind at a socket path whatever its length, see shorten_path. The parent directory gets created if it does not exist. The callers name the socket in the error of a failed bind.
connection_failed ๐Ÿ”’
Whether an accept failed for the connection only, which the client aborted or reset before it got accepted.
listen_private ๐Ÿ”’
Listen on a stream socket at path which only its owner can connect to, see private_socket.
private_socket ๐Ÿ”’
Create a non-blocking UNIX socket which only its owner can connect to. Linux creates the file of a socket on bind with the mode of the socket minus the umask, so others cannot connect at any time, unlike with a chmod after the bind.
shorten_path ๐Ÿ”’
Refer to a socket path through its parent directory, so that it fits into a socket address whatever its length. The directory has to exist and stays open as long as the returned file, the path is only valid until then.
shorten_socket_path ๐Ÿ”’
Like shorten_path, creating the parent directory if it does not exist.
split_socket_path ๐Ÿ”’
Split a socket path into its parent directory and name, a relative name lives in the current directory.