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