consolidate
[m6w6/libmemcached] / src / p9y / socket.hpp
1 #pragma once
2
3 #include "libmemcached-1/platform.h"
4
5 #if defined __cplusplus
6 # include <cerrno>
7 #else
8 # include <errno.h>
9 #endif
10
11 #include <fcntl.h>
12
13 #if defined HAVE_ARPA_INET_H
14 # include <arpa/inet.h>
15 #endif
16
17 #if defined HAVE_SYS_SOCKET_H
18 # include <sys/socket.h>
19 #endif
20
21 #if defined HAVE_NETINET_IN_H
22 # include <netinet/in.h>
23 #endif
24
25 #if defined HAVE_NETINET_TCP_H
26 # include <netinet/tcp.h>
27 #endif
28
29 #if defined HAVE_SYS_UN_H
30 # include <sys/un.h>
31 #endif
32
33 #if defined HAVE_UNISTD_H
34 # include <unistd.h>
35 #endif
36
37 #if defined __cplusplus
38 extern "C" {
39 #endif
40
41 # if defined _WIN32
42 # define P9Y_NEED_GET_SOCKET_ERRNO
43 int get_socket_errno();
44 # define SHUT_WR SD_SEND
45 # define SHUT_RD SD_RECEIVE
46 # define SHUT_RDWR SD_BOTH
47 # else
48 # define closesocket close
49 # define get_socket_errno() errno
50 # define INVALID_SOCKET (-1)
51 # define SOCKET_ERROR (-1)
52 # endif
53
54 #if defined __cplusplus
55 }
56 #endif
57
58 #if !defined SOCK_CLOEXEC
59 # define SOCK_CLOEXEC 0
60 #endif
61
62 #if !defined SOCK_NONBLOCK
63 # define SOCK_NONBLOCK 0
64 #endif
65
66 #if !defined FD_CLOEXEC
67 # define FD_CLOEXEC 0
68 #endif
69
70 #if !defined SO_NOSIGPIPE
71 # define SO_NOSIGPIPE 0
72 #endif
73
74 #if !defined TCP_NODELAY
75 # define TCP_NODELAY 0
76 #endif
77
78 #if !defined TCP_KEEPIDLE
79 # define TCP_KEEPIDLE 0
80 #endif
81
82 #if !defined EAI_SYSTEM
83 # define EAI_SYSTEM (-1)
84 #endif
85
86 #if !defined HAVE_MSG_NOSIGNAL
87 # define MSG_NOSIGNAL 0
88 #endif
89
90 #if !defined HAVE_MSG_MORE
91 # define MSG_MORE 0
92 #endif