Nix 2.26.3
Nix, the purely functional package manager; unstable internal interfaces
 
Loading...
Searching...
No Matches
unix-domain-socket.hh
Go to the documentation of this file.
1#pragma once
3
4#include "types.hh"
5#include "file-descriptor.hh"
6
7#ifdef _WIN32
8# include <winsock2.h>
9#endif
10#include <unistd.h>
11
12namespace nix {
13
17AutoCloseFD createUnixDomainSocket();
18
22AutoCloseFD createUnixDomainSocket(const Path & path, mode_t mode);
23
29using Socket =
30#ifdef _WIN32
31 SOCKET
32#else
33 int
34#endif
35 ;
36
37#ifdef _WIN32
41# define SHUT_WR SD_SEND
42# define SHUT_RDWR SD_BOTH
43#endif
44
50static inline Socket toSocket(Descriptor fd)
51{
52#ifdef _WIN32
53 return reinterpret_cast<Socket>(fd);
54#else
55 return fd;
56#endif
57}
58
64static inline Descriptor fromSocket(Socket fd)
65{
66#ifdef _WIN32
67 return reinterpret_cast<Descriptor>(fd);
68#else
69 return fd;
70#endif
71}
72
76void bind(Socket fd, const std::string & path);
77
81void connect(Socket fd, const std::string & path);
82
83}
Definition file-descriptor.hh:152
int Descriptor
Definition file-descriptor.hh:20
return fd
Definition lexer.l:2948
std::string Path
Definition types.hh:22
int Socket
Definition unix-domain-socket.hh:29