339b5995bf285465e160c8989b12c563fdda8a5b
[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_SYS_UN_H
20 # include <sys/un.h>
21 #endif
22
23 #if defined HAVE_UNISTD_H
24 # include <unistd.h>
25 #endif
26
27 #if defined __cplusplus
28 extern "C" {
29 #endif
30
31 # if defined _WIN32
32 int get_socket_errno();
33 # define SHUT_WR SD_SEND
34 # define SHUT_RD SD_RECEIVE
35 # define SHUT_RDWR SD_BOTH
36 # else
37 # define closesocket close
38 # define get_socket_errno() errno
39 # define INVALID_SOCKET (-1)
40 # define SOCKET_ERROR (-1)
41 # endif
42
43 #if defined __cplusplus
44 }
45 #endif
46
47 #if !defined SOCK_CLOEXEC
48 # define SOCK_CLOEXEC 0
49 #endif
50
51 #if !defined SOCK_NONBLOCK
52 # define SOCK_NONBLOCK 0
53 #endif
54
55 #if !defined FD_CLOEXEC
56 # define FD_CLOEXEC 0
57 #endif
58
59 #if !defined SO_NOSIGPIPE
60 # define SO_NOSIGPIPE 0
61 #endif
62
63 #if !defined TCP_NODELAY
64 # define TCP_NODELAY 0
65 #endif
66
67 #if !defined TCP_KEEPIDLE
68 # define TCP_KEEPIDLE 0
69 #endif
70
71 #if !defined EAI_SYSTEM
72 # define EAI_SYSTEM (-1)
73 #endif
74
75 #if !defined HAVE_MSG_NOSIGNAL
76 # define MSG_NOSIGNAL 0
77 #endif
78
79 #if !defined HAVE_MSG_MORE
80 # define MSG_MORE 0
81 #endif