![]() |
Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
|
#include "nix/util/file-descriptor.hh"#include <filesystem>#include <functional>#include <optional>#include <sys/types.h>Go to the source code of this file.
Classes | |
| struct | nix::unix::PeerInfo |
| struct | nix::unix::ServeUnixSocketOptions |
Typedefs | |
| using | nix::unix::UnixSocketHandler = fun<void(AutoCloseFD socket)> |
Functions | |
| PeerInfo | nix::unix::getPeerInfo (Descriptor remote) |
| nix::unix::MakeError (AbortServeSocket, BaseError) | |
| void | nix::unix::serveUnixSocket (const ServeUnixSocketOptions &options, UnixSocketHandler handler) |
| using nix::unix::UnixSocketHandler = fun<void(AutoCloseFD socket)> |
Callback type for handling new connections.
The callback receives ownership of the connection and is responsible for handling it (e.g., forking a child process, spawning a thread, etc.).
| socket | The accepted connection file descriptor. |
| PeerInfo nix::unix::getPeerInfo | ( | Descriptor | remote | ) |
Get the identity of the caller, if possible.
| void nix::unix::serveUnixSocket | ( | const ServeUnixSocketOptions & | options, |
| UnixSocketHandler | handler ) |
Run a server loop that accepts connections and calls the handler for each.
This function handles:
For each accepted connection, the handler is called with the connection file descriptor. The handler takes ownership of the file descriptor and is responsible for closing it when done.
This function never returns normally. It runs until interrupted (e.g., via SIGINT), at which point it throws Interrupted. Can be explicitly exited by throwing AbortServeSocket.
| options | Configuration for the server. |
| handler | Callback invoked for each accepted connection. |