1 | // |
---|
2 | // SocketDefs.h |
---|
3 | // |
---|
4 | // $Id: //poco/1.3/Net/include/Poco/Net/SocketDefs.h#3 $ |
---|
5 | // |
---|
6 | // Library: Net |
---|
7 | // Package: NetCore |
---|
8 | // Module: SocketDefs |
---|
9 | // |
---|
10 | // Include platform-specific header files for sockets. |
---|
11 | // |
---|
12 | // Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH. |
---|
13 | // and Contributors. |
---|
14 | // |
---|
15 | // Permission is hereby granted, free of charge, to any person or organization |
---|
16 | // obtaining a copy of the software and accompanying documentation covered by |
---|
17 | // this license (the "Software") to use, reproduce, display, distribute, |
---|
18 | // execute, and transmit the Software, and to prepare derivative works of the |
---|
19 | // Software, and to permit third-parties to whom the Software is furnished to |
---|
20 | // do so, all subject to the following: |
---|
21 | // |
---|
22 | // The copyright notices in the Software and this entire statement, including |
---|
23 | // the above license grant, this restriction and the following disclaimer, |
---|
24 | // must be included in all copies of the Software, in whole or in part, and |
---|
25 | // all derivative works of the Software, unless such copies or derivative |
---|
26 | // works are solely in the form of machine-executable object code generated by |
---|
27 | // a source language processor. |
---|
28 | // |
---|
29 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
30 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
31 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT |
---|
32 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE |
---|
33 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, |
---|
34 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
---|
35 | // DEALINGS IN THE SOFTWARE. |
---|
36 | // |
---|
37 | |
---|
38 | |
---|
39 | #ifndef Net_SocketDefs_INCLUDED |
---|
40 | #define Net_SocketDefs_INCLUDED |
---|
41 | |
---|
42 | |
---|
43 | #if defined(POCO_OS_FAMILY_WINDOWS) |
---|
44 | #include "Poco/UnWindows.h" |
---|
45 | #include <winsock2.h> |
---|
46 | #include <ws2tcpip.h> |
---|
47 | #define POCO_INVALID_SOCKET INVALID_SOCKET |
---|
48 | #define poco_socket_t SOCKET |
---|
49 | #define poco_socklen_t int |
---|
50 | #define poco_closesocket(s) closesocket(s) |
---|
51 | #define POCO_EINTR WSAEINTR |
---|
52 | #define POCO_EACCES WSAEACCES |
---|
53 | #define POCO_EFAULT WSAEFAULT |
---|
54 | #define POCO_EINVAL WSAEINVAL |
---|
55 | #define POCO_EMFILE WSAEMFILE |
---|
56 | #define POCO_EAGAIN WSAEWOULDBLOCK |
---|
57 | #define POCO_EWOULDBLOCK WSAEWOULDBLOCK |
---|
58 | #define POCO_EINPROGRESS WSAEINPROGRESS |
---|
59 | #define POCO_EALREADY WSAEALREADY |
---|
60 | #define POCO_ENOTSOCK WSAENOTSOCK |
---|
61 | #define POCO_EDESTADDRREQ WSAEDESTADDRREQ |
---|
62 | #define POCO_EMSGSIZE WSAEMSGSIZE |
---|
63 | #define POCO_EPROTOTYPE WSAEPROTOTYPE |
---|
64 | #define POCO_ENOPROTOOPT WSAENOPROTOOPT |
---|
65 | #define POCO_EPROTONOSUPPORT WSAEPROTONOSUPPORT |
---|
66 | #define POCO_ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT |
---|
67 | #define POCO_ENOTSUP WSAEOPNOTSUPP |
---|
68 | #define POCO_EPFNOSUPPORT WSAEPFNOSUPPORT |
---|
69 | #define POCO_EAFNOSUPPORT WSAEAFNOSUPPORT |
---|
70 | #define POCO_EADDRINUSE WSAEADDRINUSE |
---|
71 | #define POCO_EADDRNOTAVAIL WSAEADDRNOTAVAIL |
---|
72 | #define POCO_ENETDOWN WSAENETDOWN |
---|
73 | #define POCO_ENETUNREACH WSAENETUNREACH |
---|
74 | #define POCO_ENETRESET WSAENETRESET |
---|
75 | #define POCO_ECONNABORTED WSAECONNABORTED |
---|
76 | #define POCO_ECONNRESET WSAECONNRESET |
---|
77 | #define POCO_ENOBUFS WSAENOBUFS |
---|
78 | #define POCO_EISCONN WSAEISCONN |
---|
79 | #define POCO_ENOTCONN WSAENOTCONN |
---|
80 | #define POCO_ESHUTDOWN WSAESHUTDOWN |
---|
81 | #define POCO_ETIMEDOUT WSAETIMEDOUT |
---|
82 | #define POCO_ECONNREFUSED WSAECONNREFUSED |
---|
83 | #define POCO_EHOSTDOWN WSAEHOSTDOWN |
---|
84 | #define POCO_EHOSTUNREACH WSAEHOSTUNREACH |
---|
85 | #define POCO_ESYSNOTREADY WSASYSNOTREADY |
---|
86 | #define POCO_ENOTINIT WSANOTINITIALISED |
---|
87 | #define POCO_HOST_NOT_FOUND WSAHOST_NOT_FOUND |
---|
88 | #define POCO_TRY_AGAIN WSATRY_AGAIN |
---|
89 | #define POCO_NO_RECOVERY WSANO_RECOVERY |
---|
90 | #define POCO_NO_DATA WSANO_DATA |
---|
91 | #elif defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_VMS) |
---|
92 | #include <unistd.h> |
---|
93 | #include <errno.h> |
---|
94 | #include <sys/types.h> |
---|
95 | #include <sys/socket.h> |
---|
96 | #if POCO_OS != POCO_OS_HPUX |
---|
97 | #include <sys/select.h> |
---|
98 | #endif |
---|
99 | #include <sys/ioctl.h> |
---|
100 | #if defined(POCO_OS_FAMILY_VMS) |
---|
101 | #include <inet.h> |
---|
102 | #else |
---|
103 | #include <arpa/inet.h> |
---|
104 | #endif |
---|
105 | #include <netinet/in.h> |
---|
106 | #include <netinet/tcp.h> |
---|
107 | #include <netdb.h> |
---|
108 | #if defined(POCO_OS_FAMILY_UNIX) |
---|
109 | #include <net/if.h> |
---|
110 | #endif |
---|
111 | #if defined(sun) || defined(__APPLE__) |
---|
112 | #include <sys/sockio.h> |
---|
113 | #include <sys/filio.h> |
---|
114 | #endif |
---|
115 | #define POCO_INVALID_SOCKET -1 |
---|
116 | #define poco_socket_t int |
---|
117 | #define poco_socklen_t socklen_t |
---|
118 | #define poco_closesocket(s) ::close(s) |
---|
119 | #define POCO_EINTR EINTR |
---|
120 | #define POCO_EACCES EACCES |
---|
121 | #define POCO_EFAULT EFAULT |
---|
122 | #define POCO_EINVAL EINVAL |
---|
123 | #define POCO_EMFILE EMFILE |
---|
124 | #define POCO_EAGAIN EAGAIN |
---|
125 | #define POCO_EWOULDBLOCK EWOULDBLOCK |
---|
126 | #define POCO_EINPROGRESS EINPROGRESS |
---|
127 | #define POCO_EALREADY EALREADY |
---|
128 | #define POCO_ENOTSOCK ENOTSOCK |
---|
129 | #define POCO_EDESTADDRREQ EDESTADDRREQ |
---|
130 | #define POCO_EMSGSIZE EMSGSIZE |
---|
131 | #define POCO_EPROTOTYPE EPROTOTYPE |
---|
132 | #define POCO_ENOPROTOOPT ENOPROTOOPT |
---|
133 | #define POCO_EPROTONOSUPPORT EPROTONOSUPPORT |
---|
134 | #if defined(ESOCKTNOSUPPORT) |
---|
135 | #define POCO_ESOCKTNOSUPPORT ESOCKTNOSUPPORT |
---|
136 | #else |
---|
137 | #define POCO_ESOCKTNOSUPPORT -1 |
---|
138 | #endif |
---|
139 | #define POCO_ENOTSUP ENOTSUP |
---|
140 | #define POCO_EPFNOSUPPORT EPFNOSUPPORT |
---|
141 | #define POCO_EAFNOSUPPORT EAFNOSUPPORT |
---|
142 | #define POCO_EADDRINUSE EADDRINUSE |
---|
143 | #define POCO_EADDRNOTAVAIL EADDRNOTAVAIL |
---|
144 | #define POCO_ENETDOWN ENETDOWN |
---|
145 | #define POCO_ENETUNREACH ENETUNREACH |
---|
146 | #define POCO_ENETRESET ENETRESET |
---|
147 | #define POCO_ECONNABORTED ECONNABORTED |
---|
148 | #define POCO_ECONNRESET ECONNRESET |
---|
149 | #define POCO_ENOBUFS ENOBUFS |
---|
150 | #define POCO_EISCONN EISCONN |
---|
151 | #define POCO_ENOTCONN ENOTCONN |
---|
152 | #if defined(ESHUTDOWN) |
---|
153 | #define POCO_ESHUTDOWN ESHUTDOWN |
---|
154 | #else |
---|
155 | #define POCO_ESHUTDOWN -2 |
---|
156 | #endif |
---|
157 | #define POCO_ETIMEDOUT ETIMEDOUT |
---|
158 | #define POCO_ECONNREFUSED ECONNREFUSED |
---|
159 | #if defined(EHOSTDOWN) |
---|
160 | #define POCO_EHOSTDOWN EHOSTDOWN |
---|
161 | #else |
---|
162 | #define POCO_EHOSTDOWN -3 |
---|
163 | #endif |
---|
164 | #define POCO_EHOSTUNREACH EHOSTUNREACH |
---|
165 | #define POCO_ESYSNOTREADY -4 |
---|
166 | #define POCO_ENOTINIT -5 |
---|
167 | #define POCO_HOST_NOT_FOUND HOST_NOT_FOUND |
---|
168 | #define POCO_TRY_AGAIN TRY_AGAIN |
---|
169 | #define POCO_NO_RECOVERY NO_RECOVERY |
---|
170 | #define POCO_NO_DATA NO_DATA |
---|
171 | #endif |
---|
172 | |
---|
173 | |
---|
174 | #if defined(POCO_OS_FAMILY_BSD) || (POCO_OS == POCO_OS_TRU64) || (POCO_OS == POCO_OS_AIX) || (POCO_OS == POCO_OS_IRIX) || (POCO_OS == POCO_OS_QNX) || (POCO_OS == POCO_OS_VXWORKS) |
---|
175 | #define POCO_HAVE_SALEN 1 |
---|
176 | #endif |
---|
177 | |
---|
178 | |
---|
179 | #if (POCO_OS == POCO_OS_HPUX) || (POCO_OS == POCO_OS_SOLARIS) |
---|
180 | #define POCO_BROKEN_TIMEOUTS 1 |
---|
181 | #endif |
---|
182 | |
---|
183 | |
---|
184 | #if defined(POCO_HAVE_SALEN) |
---|
185 | #define poco_set_sa_len(pSA, len) (pSA)->sa_len = (len) |
---|
186 | #define poco_set_sin_len(pSA) (pSA)->sin_len = sizeof(struct sockaddr_in) |
---|
187 | #if defined(POCO_HAVE_IPv6) |
---|
188 | #define poco_set_sin6_len(pSA) (pSA)->sin6_len = sizeof(struct sockaddr_in6) |
---|
189 | #endif |
---|
190 | #else |
---|
191 | #define poco_set_sa_len(pSA, len) (void) 0 |
---|
192 | #define poco_set_sin_len(pSA) (void) 0 |
---|
193 | #define poco_set_sin6_len(pSA) (void) 0 |
---|
194 | #endif |
---|
195 | |
---|
196 | |
---|
197 | #ifndef INADDR_NONE |
---|
198 | #define INADDR_NONE 0xFFFFFFFF |
---|
199 | #endif |
---|
200 | |
---|
201 | |
---|
202 | #endif // Net_SocketDefs_INCLUDED |
---|