Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
socket.hh
Go to the documentation of this file.
1#pragma once
3
5
6#ifdef _WIN32
7# include <winsock2.h>
8#endif
9
10namespace nix {
11
17using Socket =
18#ifdef _WIN32
19 SOCKET
20#else
21 int
22#endif
23 ;
24
25#ifdef _WIN32
29# define SHUT_WR SD_SEND
30# define SHUT_RDWR SD_BOTH
31#endif
32
38static inline Socket toSocket(Descriptor fd)
39{
40#ifdef _WIN32
41 return reinterpret_cast<Socket>(fd);
42#else
43 return fd;
44#endif
45}
46
52static inline Descriptor fromSocket(Socket fd)
53{
54#ifdef _WIN32
55 return reinterpret_cast<Descriptor>(fd);
56#else
57 return fd;
58#endif
59}
60
61} // namespace nix
File descriptor operations for almost arbitrary file descriptors.
int Descriptor
Definition file-descriptor.hh:36
int Socket
Definition socket.hh:17