![]() |
Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
|
#include "nix/util/types.hh"#include "nix/util/file-descriptor.hh"#include "nix/util/socket.hh"#include <filesystem>#include <span>#include <vector>#include <unistd.h>Go to the source code of this file.
Classes | |
| struct | nix::unix::ReceivedMessage |
Functions | |
| AutoCloseFD | nix::createUnixDomainSocket () |
| AutoCloseFD | nix::createUnixDomainSocket (const std::filesystem::path &path, mode_t mode) |
| void | nix::bind (Socket fd, const std::filesystem::path &path) |
| void | nix::connect (Socket fd, const std::filesystem::path &path) |
| AutoCloseFD | nix::connect (const std::filesystem::path &path) |
| void | nix::unix::sendMessageWithFds (Descriptor sockfd, std::span< const std::byte > data, std::span< const Descriptor > fds) |
| ReceivedMessage | nix::unix::receiveMessageWithFds (Descriptor sockfd, std::span< std::byte > data) |
| void nix::bind | ( | Socket | fd, |
| const std::filesystem::path & | path ) |
Bind a Unix domain socket to a path.
| AutoCloseFD nix::connect | ( | const std::filesystem::path & | path | ) |
Connect to a Unix domain socket.
| void nix::connect | ( | Socket | fd, |
| const std::filesystem::path & | path ) |
Connect to a Unix domain socket.
| AutoCloseFD nix::createUnixDomainSocket | ( | ) |
Create a Unix domain socket.
| AutoCloseFD nix::createUnixDomainSocket | ( | const std::filesystem::path & | path, |
| mode_t | mode ) |
Create a Unix domain socket in listen mode.
| unix::ReceivedMessage nix::unix::receiveMessageWithFds | ( | Descriptor | sockfd, |
| std::span< std::byte > | data ) |
Receive a message with file descriptors over a Unix domain socket using recvmsg with SCM_RIGHTS.
All file descriptors associated with the message will be returned. This avoids unrecoverably dropping file descriptors with a messages. This is why a vector is returned, as opposed to the caller passing in a std::span with length of their choosing, as that may not be long enough.
| sockfd | The socket file descriptor to receive the message on |
| data | Buffer to receive data into |
| SysError | on failure |
| EndOfFile | if the connection is closed |
| void nix::unix::sendMessageWithFds | ( | Descriptor | sockfd, |
| std::span< const std::byte > | data, | ||
| std::span< const Descriptor > | fds ) |
Send a message with file descriptors over a Unix domain socket using sendmsg with SCM_RIGHTS.
On SOCK_STREAM sockets, data must be non-empty when fds is non-empty, because the kernel silently drops ancillary data on zero-length stream sends.
| sockfd | The socket file descriptor to send the message on |
| data | The data to send |
| fds | A span of file descriptors to pass via SCM_RIGHTS |
| SysError | on failure |