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 ASIO_DETAIL_SOCKET_TYPES_HPP
12
#define ASIO_DETAIL_SOCKET_TYPES_HPP
14
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
16
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18
#include "asio/detail/push_options.hpp"
20
#include "asio/detail/push_options.hpp"
21
#include <boost/config.hpp>
22
#include "asio/detail/pop_options.hpp"
24
#include "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__)
31
# pragma message("Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately")
32
# pragma message("Assuming _WIN32_WINNT=0x0501 (i.e. Windows XP target)")
33
# else // defined(_MSC_VER) || defined(__BORLANDC__)
34
# warning Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately
35
# warning Assuming _WIN32_WINNT=0x0501 (i.e. Windows XP target)
36
# endif // defined(_MSC_VER) || defined(__BORLANDC__)
37
# define _WIN32_WINNT 0x0501
38
# endif // !defined(_WIN32_WINNT) && !defined(_WIN32_WINDOWS)
39
# if defined(_MSC_VER)
40
# if defined(_WIN32) && !defined(WIN32)
41
# if !defined(_WINSOCK2API_)
42
# define WIN32 // Needed for correct types in winsock2.h
43
# else // !defined(_WINSOCK2API_)
44
# error Please define the macro WIN32 in your compiler options
45
# endif // !defined(_WINSOCK2API_)
46
# endif // defined(_WIN32) && !defined(WIN32)
47
# endif // defined(_MSC_VER)
48
# if defined(__BORLANDC__)
49
# include <stdlib.h> // Needed for __errno
50
# if defined(__WIN32__) && !defined(WIN32)
51
# if !defined(_WINSOCK2API_)
52
# define WIN32 // Needed for correct types in winsock2.h
53
# else // !defined(_WINSOCK2API_)
54
# error Please define the macro WIN32 in your compiler options
55
# endif // !defined(_WINSOCK2API_)
56
# endif // defined(__WIN32__) && !defined(WIN32)
57
# if !defined(_WSPIAPI_H_)
59
# define ASIO_WSPIAPI_H_DEFINED
60
# endif // !defined(_WSPIAPI_H_)
61
# endif // defined(__BORLANDC__)
62
# if !defined(ASIO_NO_WIN32_LEAN_AND_MEAN)
63
# if !defined(WIN32_LEAN_AND_MEAN)
64
# define WIN32_LEAN_AND_MEAN
65
# endif // !defined(WIN32_LEAN_AND_MEAN)
66
# endif // !defined(ASIO_NO_WIN32_LEAN_AND_MEAN)
67
# if defined(__CYGWIN__)
68
# if !defined(__USE_W32_SOCKETS)
69
# error You must add -D__USE_W32_SOCKETS to your compiler options.
70
# endif // !defined(__USE_W32_SOCKETS)
71
# if !defined(NOMINMAX)
73
# endif // !defined(NOMINMAX)
74
# endif // defined(__CYGWIN__)
75
# include <winsock2.h>
76
# include <ws2tcpip.h>
78
# if defined(ASIO_WSPIAPI_H_DEFINED)
80
# undef ASIO_WSPIAPI_H_DEFINED
81
# endif // defined(ASIO_WSPIAPI_H_DEFINED)
82
# if !defined(ASIO_NO_DEFAULT_LINKED_LIBS)
83
# if defined(UNDER_CE)
84
# pragma comment(lib, "ws2.lib")
85
# elif defined(_MSC_VER) || defined(__BORLANDC__)
86
# pragma comment(lib, "ws2_32.lib")
87
# pragma comment(lib, "mswsock.lib")
88
# endif // defined(_MSC_VER) || defined(__BORLANDC__)
89
# endif // !defined(ASIO_NO_DEFAULT_LINKED_LIBS)
90
# include "asio/detail/old_win_sdk_compat.hpp"
92
# include <sys/ioctl.h>
93
# include <sys/poll.h>
94
# include <sys/types.h>
95
# if defined(__hpux) && !defined(__HP_aCC)
96
# include <sys/time.h>
98
# include <sys/select.h>
100
# include <sys/socket.h>
101
# include <sys/uio.h>
102
# include <netinet/in.h>
103
# include <netinet/tcp.h>
104
# include <arpa/inet.h>
109
# include <sys/filio.h>
110
# include <sys/sockio.h>
113
#include "asio/detail/pop_options.hpp"
118
#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
119
typedef SOCKET socket_type;
120
const SOCKET invalid_socket = INVALID_SOCKET;
121
const int socket_error_retval = SOCKET_ERROR;
122
const int max_addr_v4_str_len = 256;
123
const int max_addr_v6_str_len = 256;
124
typedef sockaddr socket_addr_type;
125
typedef in_addr in4_addr_type;
126
typedef ip_mreq in4_mreq_type;
127
typedef sockaddr_in sockaddr_in4_type;
128
# if defined(ASIO_HAS_OLD_WIN_SDK)
129
typedef in6_addr_emulation in6_addr_type;
130
typedef ipv6_mreq_emulation in6_mreq_type;
131
typedef sockaddr_in6_emulation sockaddr_in6_type;
132
typedef sockaddr_storage_emulation sockaddr_storage_type;
133
typedef addrinfo_emulation addrinfo_type;
135
typedef in6_addr in6_addr_type;
136
typedef ipv6_mreq in6_mreq_type;
137
typedef sockaddr_in6 sockaddr_in6_type;
138
typedef sockaddr_storage sockaddr_storage_type;
139
typedef addrinfo addrinfo_type;
141
typedef unsigned long ioctl_arg_type;
142
typedef u_long u_long_type;
143
typedef u_short u_short_type;
144
const int shutdown_receive = SD_RECEIVE;
145
const int shutdown_send = SD_SEND;
146
const int shutdown_both = SD_BOTH;
147
const int message_peek = MSG_PEEK;
148
const int message_out_of_band = MSG_OOB;
149
const int message_do_not_route = MSG_DONTROUTE;
150
# if defined (_WIN32_WINNT)
151
const int max_iov_len = 64;
153
const int max_iov_len = 16;
156
typedef int socket_type;
157
const int invalid_socket = -1;
158
const int socket_error_retval = -1;
159
const int max_addr_v4_str_len = INET_ADDRSTRLEN;
160
const int max_addr_v6_str_len = INET6_ADDRSTRLEN + 1 + IF_NAMESIZE;
161
typedef sockaddr socket_addr_type;
162
typedef in_addr in4_addr_type;
164
// HP-UX doesn't provide ip_mreq when _XOPEN_SOURCE_EXTENDED is defined.
167
struct in_addr imr_multiaddr;
168
struct in_addr imr_interface;
171
typedef ip_mreq in4_mreq_type;
173
typedef sockaddr_in sockaddr_in4_type;
174
typedef in6_addr in6_addr_type;
175
typedef ipv6_mreq in6_mreq_type;
176
typedef sockaddr_in6 sockaddr_in6_type;
177
typedef sockaddr_storage sockaddr_storage_type;
178
typedef addrinfo addrinfo_type;
179
typedef int ioctl_arg_type;
180
typedef uint32_t u_long_type;
181
typedef uint16_t u_short_type;
182
const int shutdown_receive = SHUT_RD;
183
const int shutdown_send = SHUT_WR;
184
const int shutdown_both = SHUT_RDWR;
185
const int message_peek = MSG_PEEK;
186
const int message_out_of_band = MSG_OOB;
187
const int message_do_not_route = MSG_DONTROUTE;
188
const int max_iov_len = IOV_MAX;
190
const int custom_socket_option_level = 0xA5100000;
191
const int enable_connection_aborted_option = 1;
192
const int always_fail_option = 2;
194
} // namespace detail
197
#include "asio/detail/pop_options.hpp"
199
#endif // ASIO_DETAIL_SOCKET_TYPES_HPP