2 // detail/socket_types.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2011 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/config.hpp>
20 #if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
21 # if defined(_WINSOCKAPI_) && !defined(_WINSOCK2API_)
22 # error WinSock.h has already been included
23 # endif // defined(_WINSOCKAPI_) && !defined(_WINSOCK2API_)
24 # if defined(__BORLANDC__)
25 # include <stdlib.h> // Needed for __errno
26 # if !defined(_WSPIAPI_H_)
28 # define BOOST_ASIO_WSPIAPI_H_DEFINED
29 # endif // !defined(_WSPIAPI_H_)
30 # endif // defined(__BORLANDC__)
31 # include <winsock2.h>
32 # include <ws2tcpip.h>
34 # if defined(BOOST_ASIO_WSPIAPI_H_DEFINED)
36 # undef BOOST_ASIO_WSPIAPI_H_DEFINED
37 # endif // defined(BOOST_ASIO_WSPIAPI_H_DEFINED)
38 # if !defined(BOOST_ASIO_NO_DEFAULT_LINKED_LIBS)
39 # if defined(UNDER_CE)
40 # pragma comment(lib, "ws2.lib")
41 # elif defined(_MSC_VER) || defined(__BORLANDC__)
42 # pragma comment(lib, "ws2_32.lib")
43 # pragma comment(lib, "mswsock.lib")
44 # endif // defined(_MSC_VER) || defined(__BORLANDC__)
45 # endif // !defined(BOOST_ASIO_NO_DEFAULT_LINKED_LIBS)
46 # include <boost/asio/detail/old_win_sdk_compat.hpp>
48 # include <sys/ioctl.h>
49 # if !defined(__SYMBIAN32__)
50 # include <sys/poll.h>
52 # include <sys/types.h>
53 # include <sys/stat.h>
56 # include <sys/time.h>
58 # if !defined(__hpux) || defined(__SELECT)
59 # include <sys/select.h>
61 # include <sys/socket.h>
64 # include <netinet/in.h>
65 # if !defined(__SYMBIAN32__)
66 # include <netinet/tcp.h>
68 # include <arpa/inet.h>
73 # include <sys/filio.h>
74 # include <sys/sockio.h>
78 #include <boost/asio/detail/push_options.hpp>
84 #if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
85 typedef SOCKET socket_type;
86 const SOCKET invalid_socket = INVALID_SOCKET;
87 const int socket_error_retval = SOCKET_ERROR;
88 const int max_addr_v4_str_len = 256;
89 const int max_addr_v6_str_len = 256;
90 typedef sockaddr socket_addr_type;
91 typedef in_addr in4_addr_type;
92 typedef ip_mreq in4_mreq_type;
93 typedef sockaddr_in sockaddr_in4_type;
94 # if defined(BOOST_ASIO_HAS_OLD_WIN_SDK)
95 typedef in6_addr_emulation in6_addr_type;
96 typedef ipv6_mreq_emulation in6_mreq_type;
97 typedef sockaddr_in6_emulation sockaddr_in6_type;
98 typedef sockaddr_storage_emulation sockaddr_storage_type;
99 typedef addrinfo_emulation addrinfo_type;
101 typedef in6_addr in6_addr_type;
102 typedef ipv6_mreq in6_mreq_type;
103 typedef sockaddr_in6 sockaddr_in6_type;
104 typedef sockaddr_storage sockaddr_storage_type;
105 typedef addrinfo addrinfo_type;
107 typedef unsigned long ioctl_arg_type;
108 typedef u_long u_long_type;
109 typedef u_short u_short_type;
110 const int shutdown_receive = SD_RECEIVE;
111 const int shutdown_send = SD_SEND;
112 const int shutdown_both = SD_BOTH;
113 const int message_peek = MSG_PEEK;
114 const int message_out_of_band = MSG_OOB;
115 const int message_do_not_route = MSG_DONTROUTE;
116 const int message_end_of_record = 0; // Not supported on Windows.
117 # if defined (_WIN32_WINNT)
118 const int max_iov_len = 64;
120 const int max_iov_len = 16;
123 typedef int socket_type;
124 const int invalid_socket = -1;
125 const int socket_error_retval = -1;
126 const int max_addr_v4_str_len = INET_ADDRSTRLEN;
127 #if defined(INET6_ADDRSTRLEN)
128 const int max_addr_v6_str_len = INET6_ADDRSTRLEN + 1 + IF_NAMESIZE;
129 #else // defined(INET6_ADDRSTRLEN)
130 const int max_addr_v6_str_len = 256;
131 #endif // defined(INET6_ADDRSTRLEN)
132 typedef sockaddr socket_addr_type;
133 typedef in_addr in4_addr_type;
135 // HP-UX doesn't provide ip_mreq when _XOPEN_SOURCE_EXTENDED is defined.
138 struct in_addr imr_multiaddr;
139 struct in_addr imr_interface;
142 typedef ip_mreq in4_mreq_type;
144 typedef sockaddr_in sockaddr_in4_type;
145 typedef in6_addr in6_addr_type;
146 typedef ipv6_mreq in6_mreq_type;
147 typedef sockaddr_in6 sockaddr_in6_type;
148 typedef sockaddr_storage sockaddr_storage_type;
149 typedef sockaddr_un sockaddr_un_type;
150 typedef addrinfo addrinfo_type;
151 typedef int ioctl_arg_type;
152 typedef uint32_t u_long_type;
153 typedef uint16_t u_short_type;
154 const int shutdown_receive = SHUT_RD;
155 const int shutdown_send = SHUT_WR;
156 const int shutdown_both = SHUT_RDWR;
157 const int message_peek = MSG_PEEK;
158 const int message_out_of_band = MSG_OOB;
159 const int message_do_not_route = MSG_DONTROUTE;
160 const int message_end_of_record = MSG_EOR;
161 # if defined(IOV_MAX)
162 const int max_iov_len = IOV_MAX;
164 // POSIX platforms are not required to define IOV_MAX.
165 const int max_iov_len = 16;
168 const int custom_socket_option_level = 0xA5100000;
169 const int enable_connection_aborted_option = 1;
170 const int always_fail_option = 2;
172 } // namespace detail
176 #include <boost/asio/detail/pop_options.hpp>
178 #endif // BOOST_ASIO_DETAIL_SOCKET_TYPES_HPP