5 // Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_ASIO_DETAIL_SOCKET_TYPES_HPP
12 #define BOOST_ASIO_DETAIL_SOCKET_TYPES_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/push_options.hpp>
20 #include <boost/asio/detail/push_options.hpp>
21 #include <boost/config.hpp>
22 #include <boost/asio/detail/pop_options.hpp>
24 #include <boost/asio/detail/push_options.hpp>
25 #if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
26 # if defined(_WINSOCKAPI_) && !defined(_WINSOCK2API_)
27 # error WinSock.h has already been included
28 # endif // defined(_WINSOCKAPI_) && !defined(_WINSOCK2API_)
29 # if !defined(_WIN32_WINNT) && !defined(_WIN32_WINDOWS)
30 # if defined(_MSC_VER) || defined(__BORLANDC__)
32 "Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately. For example:\n"\
33 "- add -D_WIN32_WINNT=0x0501 to the compiler command line; or\n"\
34 "- add _WIN32_WINNT=0x0501 to your project's Preprocessor Definitions.\n"\
35 "Assuming _WIN32_WINNT=0x0501 (i.e. Windows XP target).")
36 # else // defined(_MSC_VER) || defined(__BORLANDC__)
37 # warning Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately.
38 # warning For example, add -D_WIN32_WINNT=0x0501 to the compiler command line.
39 # warning Assuming _WIN32_WINNT=0x0501 (i.e. Windows XP target).
40 # endif // defined(_MSC_VER) || defined(__BORLANDC__)
41 # define _WIN32_WINNT 0x0501
42 # endif // !defined(_WIN32_WINNT) && !defined(_WIN32_WINDOWS)
43 # if defined(_MSC_VER)
44 # if defined(_WIN32) && !defined(WIN32)
45 # if !defined(_WINSOCK2API_)
46 # define WIN32 // Needed for correct types in winsock2.h
47 # else // !defined(_WINSOCK2API_)
48 # error Please define the macro WIN32 in your compiler options
49 # endif // !defined(_WINSOCK2API_)
50 # endif // defined(_WIN32) && !defined(WIN32)
51 # endif // defined(_MSC_VER)
52 # if defined(__BORLANDC__)
53 # include <stdlib.h> // Needed for __errno
54 # if defined(__WIN32__) && !defined(WIN32)
55 # if !defined(_WINSOCK2API_)
56 # define WIN32 // Needed for correct types in winsock2.h
57 # else // !defined(_WINSOCK2API_)
58 # error Please define the macro WIN32 in your compiler options
59 # endif // !defined(_WINSOCK2API_)
60 # endif // defined(__WIN32__) && !defined(WIN32)
61 # if !defined(_WSPIAPI_H_)
63 # define BOOST_ASIO_WSPIAPI_H_DEFINED
64 # endif // !defined(_WSPIAPI_H_)
65 # endif // defined(__BORLANDC__)
66 # if !defined(BOOST_ASIO_NO_WIN32_LEAN_AND_MEAN)
67 # if !defined(WIN32_LEAN_AND_MEAN)
68 # define WIN32_LEAN_AND_MEAN
69 # endif // !defined(WIN32_LEAN_AND_MEAN)
70 # endif // !defined(BOOST_ASIO_NO_WIN32_LEAN_AND_MEAN)
71 # if defined(__CYGWIN__)
72 # if !defined(__USE_W32_SOCKETS)
73 # error You must add -D__USE_W32_SOCKETS to your compiler options.
74 # endif // !defined(__USE_W32_SOCKETS)
75 # if !defined(NOMINMAX)
77 # endif // !defined(NOMINMAX)
78 # endif // defined(__CYGWIN__)
79 # include <winsock2.h>
80 # include <ws2tcpip.h>
82 # if defined(BOOST_ASIO_WSPIAPI_H_DEFINED)
84 # undef BOOST_ASIO_WSPIAPI_H_DEFINED
85 # endif // defined(BOOST_ASIO_WSPIAPI_H_DEFINED)
86 # if !defined(BOOST_ASIO_NO_DEFAULT_LINKED_LIBS)
87 # if defined(UNDER_CE)
88 # pragma comment(lib, "ws2.lib")
89 # elif defined(_MSC_VER) || defined(__BORLANDC__)
90 # pragma comment(lib, "ws2_32.lib")
91 # pragma comment(lib, "mswsock.lib")
92 # endif // defined(_MSC_VER) || defined(__BORLANDC__)
93 # endif // !defined(BOOST_ASIO_NO_DEFAULT_LINKED_LIBS)
94 # include <boost/asio/detail/old_win_sdk_compat.hpp>
96 # include <sys/ioctl.h>
97 # include <sys/poll.h>
98 # include <sys/types.h>
99 # if defined(__hpux) && !defined(__HP_aCC)
100 # include <sys/time.h>
102 # include <sys/select.h>
104 # include <sys/socket.h>
105 # include <sys/uio.h>
107 # include <netinet/in.h>
108 # include <netinet/tcp.h>
109 # include <arpa/inet.h>
114 # include <sys/filio.h>
115 # include <sys/sockio.h>
118 #include <boost/asio/detail/pop_options.hpp>
124 #if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
125 typedef SOCKET socket_type
;
126 const SOCKET invalid_socket
= INVALID_SOCKET
;
127 const int socket_error_retval
= SOCKET_ERROR
;
128 const int max_addr_v4_str_len
= 256;
129 const int max_addr_v6_str_len
= 256;
130 typedef sockaddr socket_addr_type
;
131 typedef in_addr in4_addr_type
;
132 typedef ip_mreq in4_mreq_type
;
133 typedef sockaddr_in sockaddr_in4_type
;
134 # if defined(BOOST_ASIO_HAS_OLD_WIN_SDK)
135 typedef in6_addr_emulation in6_addr_type
;
136 typedef ipv6_mreq_emulation in6_mreq_type
;
137 typedef sockaddr_in6_emulation sockaddr_in6_type
;
138 typedef sockaddr_storage_emulation sockaddr_storage_type
;
139 typedef addrinfo_emulation addrinfo_type
;
141 typedef in6_addr in6_addr_type
;
142 typedef ipv6_mreq in6_mreq_type
;
143 typedef sockaddr_in6 sockaddr_in6_type
;
144 typedef sockaddr_storage sockaddr_storage_type
;
145 typedef addrinfo addrinfo_type
;
147 typedef unsigned long ioctl_arg_type
;
148 typedef u_long u_long_type
;
149 typedef u_short u_short_type
;
150 const int shutdown_receive
= SD_RECEIVE
;
151 const int shutdown_send
= SD_SEND
;
152 const int shutdown_both
= SD_BOTH
;
153 const int message_peek
= MSG_PEEK
;
154 const int message_out_of_band
= MSG_OOB
;
155 const int message_do_not_route
= MSG_DONTROUTE
;
156 # if defined (_WIN32_WINNT)
157 const int max_iov_len
= 64;
159 const int max_iov_len
= 16;
162 typedef int socket_type
;
163 const int invalid_socket
= -1;
164 const int socket_error_retval
= -1;
165 const int max_addr_v4_str_len
= INET_ADDRSTRLEN
;
166 const int max_addr_v6_str_len
= INET6_ADDRSTRLEN
+ 1 + IF_NAMESIZE
;
167 typedef sockaddr socket_addr_type
;
168 typedef in_addr in4_addr_type
;
170 // HP-UX doesn't provide ip_mreq when _XOPEN_SOURCE_EXTENDED is defined.
173 struct in_addr imr_multiaddr
;
174 struct in_addr imr_interface
;
177 typedef ip_mreq in4_mreq_type
;
179 typedef sockaddr_in sockaddr_in4_type
;
180 typedef in6_addr in6_addr_type
;
181 typedef ipv6_mreq in6_mreq_type
;
182 typedef sockaddr_in6 sockaddr_in6_type
;
183 typedef sockaddr_storage sockaddr_storage_type
;
184 typedef sockaddr_un sockaddr_un_type
;
185 typedef addrinfo addrinfo_type
;
186 typedef int ioctl_arg_type
;
187 typedef uint32_t u_long_type
;
188 typedef uint16_t u_short_type
;
189 const int shutdown_receive
= SHUT_RD
;
190 const int shutdown_send
= SHUT_WR
;
191 const int shutdown_both
= SHUT_RDWR
;
192 const int message_peek
= MSG_PEEK
;
193 const int message_out_of_band
= MSG_OOB
;
194 const int message_do_not_route
= MSG_DONTROUTE
;
195 # if defined(IOV_MAX)
196 const int max_iov_len
= IOV_MAX
;
198 // POSIX platforms are not required to define IOV_MAX.
199 const int max_iov_len
= 16;
202 const int custom_socket_option_level
= 0xA5100000;
203 const int enable_connection_aborted_option
= 1;
204 const int always_fail_option
= 2;
206 } // namespace detail
210 #include <boost/asio/detail/pop_options.hpp>
212 #endif // BOOST_ASIO_DETAIL_SOCKET_TYPES_HPP