PageRenderTime 24ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/dependencies/boost_1_42_0/boost/asio/detail/socket_types.hpp

https://code.google.com/p/dreamofgame/
C++ Header | 216 lines | 195 code | 10 blank | 11 comment | 37 complexity | 9b335a79636ab90226b86cc885088c43 MD5 | raw file
  1. //
  2. // socket_types.hpp
  3. // ~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  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)
  9. //
  10. #ifndef BOOST_ASIO_DETAIL_SOCKET_TYPES_HPP
  11. #define BOOST_ASIO_DETAIL_SOCKET_TYPES_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <boost/asio/detail/push_options.hpp>
  16. #include <boost/asio/detail/push_options.hpp>
  17. #include <boost/config.hpp>
  18. #include <boost/asio/detail/pop_options.hpp>
  19. #include <boost/asio/detail/push_options.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(_WIN32_WINNT) && !defined(_WIN32_WINDOWS)
  25. # if defined(_MSC_VER) || defined(__BORLANDC__)
  26. # pragma message( \
  27. "Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately. For example:\n"\
  28. "- add -D_WIN32_WINNT=0x0501 to the compiler command line; or\n"\
  29. "- add _WIN32_WINNT=0x0501 to your project's Preprocessor Definitions.\n"\
  30. "Assuming _WIN32_WINNT=0x0501 (i.e. Windows XP target).")
  31. # else // defined(_MSC_VER) || defined(__BORLANDC__)
  32. # warning Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately.
  33. # warning For example, add -D_WIN32_WINNT=0x0501 to the compiler command line.
  34. # warning Assuming _WIN32_WINNT=0x0501 (i.e. Windows XP target).
  35. # endif // defined(_MSC_VER) || defined(__BORLANDC__)
  36. # define _WIN32_WINNT 0x0501
  37. # endif // !defined(_WIN32_WINNT) && !defined(_WIN32_WINDOWS)
  38. # if defined(_MSC_VER)
  39. # if defined(_WIN32) && !defined(WIN32)
  40. # if !defined(_WINSOCK2API_)
  41. # define WIN32 // Needed for correct types in winsock2.h
  42. # else // !defined(_WINSOCK2API_)
  43. # error Please define the macro WIN32 in your compiler options
  44. # endif // !defined(_WINSOCK2API_)
  45. # endif // defined(_WIN32) && !defined(WIN32)
  46. # endif // defined(_MSC_VER)
  47. # if defined(__BORLANDC__)
  48. # include <stdlib.h> // Needed for __errno
  49. # if defined(__WIN32__) && !defined(WIN32)
  50. # if !defined(_WINSOCK2API_)
  51. # define WIN32 // Needed for correct types in winsock2.h
  52. # else // !defined(_WINSOCK2API_)
  53. # error Please define the macro WIN32 in your compiler options
  54. # endif // !defined(_WINSOCK2API_)
  55. # endif // defined(__WIN32__) && !defined(WIN32)
  56. # if !defined(_WSPIAPI_H_)
  57. # define _WSPIAPI_H_
  58. # define BOOST_ASIO_WSPIAPI_H_DEFINED
  59. # endif // !defined(_WSPIAPI_H_)
  60. # endif // defined(__BORLANDC__)
  61. # if !defined(BOOST_ASIO_NO_WIN32_LEAN_AND_MEAN)
  62. # if !defined(WIN32_LEAN_AND_MEAN)
  63. # define WIN32_LEAN_AND_MEAN
  64. # endif // !defined(WIN32_LEAN_AND_MEAN)
  65. # endif // !defined(BOOST_ASIO_NO_WIN32_LEAN_AND_MEAN)
  66. # if defined(__CYGWIN__)
  67. # if !defined(__USE_W32_SOCKETS)
  68. # error You must add -D__USE_W32_SOCKETS to your compiler options.
  69. # endif // !defined(__USE_W32_SOCKETS)
  70. # if !defined(NOMINMAX)
  71. # define NOMINMAX 1
  72. # endif // !defined(NOMINMAX)
  73. # endif // defined(__CYGWIN__)
  74. # include <winsock2.h>
  75. # include <ws2tcpip.h>
  76. # include <mswsock.h>
  77. # if defined(BOOST_ASIO_WSPIAPI_H_DEFINED)
  78. # undef _WSPIAPI_H_
  79. # undef BOOST_ASIO_WSPIAPI_H_DEFINED
  80. # endif // defined(BOOST_ASIO_WSPIAPI_H_DEFINED)
  81. # if !defined(BOOST_ASIO_NO_DEFAULT_LINKED_LIBS)
  82. # if defined(UNDER_CE)
  83. # pragma comment(lib, "ws2.lib")
  84. # elif defined(_MSC_VER) || defined(__BORLANDC__)
  85. # pragma comment(lib, "ws2_32.lib")
  86. # pragma comment(lib, "mswsock.lib")
  87. # endif // defined(_MSC_VER) || defined(__BORLANDC__)
  88. # endif // !defined(BOOST_ASIO_NO_DEFAULT_LINKED_LIBS)
  89. # include <boost/asio/detail/old_win_sdk_compat.hpp>
  90. #else
  91. # include <sys/ioctl.h>
  92. # include <sys/poll.h>
  93. # include <sys/types.h>
  94. # if defined(__hpux) && !defined(__HP_aCC)
  95. # include <sys/time.h>
  96. # else
  97. # include <sys/select.h>
  98. # endif
  99. # include <sys/socket.h>
  100. # include <sys/uio.h>
  101. # include <sys/un.h>
  102. # include <netinet/in.h>
  103. # include <netinet/tcp.h>
  104. # include <arpa/inet.h>
  105. # include <netdb.h>
  106. # include <net/if.h>
  107. # include <limits.h>
  108. # if defined(__sun)
  109. # include <sys/filio.h>
  110. # include <sys/sockio.h>
  111. # endif
  112. #endif
  113. #include <boost/asio/detail/pop_options.hpp>
  114. namespace boost {
  115. namespace asio {
  116. namespace detail {
  117. #if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
  118. typedef SOCKET socket_type;
  119. const SOCKET invalid_socket = INVALID_SOCKET;
  120. const int socket_error_retval = SOCKET_ERROR;
  121. const int max_addr_v4_str_len = 256;
  122. const int max_addr_v6_str_len = 256;
  123. typedef sockaddr socket_addr_type;
  124. typedef in_addr in4_addr_type;
  125. typedef ip_mreq in4_mreq_type;
  126. typedef sockaddr_in sockaddr_in4_type;
  127. # if defined(BOOST_ASIO_HAS_OLD_WIN_SDK)
  128. typedef in6_addr_emulation in6_addr_type;
  129. typedef ipv6_mreq_emulation in6_mreq_type;
  130. typedef sockaddr_in6_emulation sockaddr_in6_type;
  131. typedef sockaddr_storage_emulation sockaddr_storage_type;
  132. typedef addrinfo_emulation addrinfo_type;
  133. # else
  134. typedef in6_addr in6_addr_type;
  135. typedef ipv6_mreq in6_mreq_type;
  136. typedef sockaddr_in6 sockaddr_in6_type;
  137. typedef sockaddr_storage sockaddr_storage_type;
  138. typedef addrinfo addrinfo_type;
  139. # endif
  140. typedef unsigned long ioctl_arg_type;
  141. typedef u_long u_long_type;
  142. typedef u_short u_short_type;
  143. const int shutdown_receive = SD_RECEIVE;
  144. const int shutdown_send = SD_SEND;
  145. const int shutdown_both = SD_BOTH;
  146. const int message_peek = MSG_PEEK;
  147. const int message_out_of_band = MSG_OOB;
  148. const int message_do_not_route = MSG_DONTROUTE;
  149. # if defined (_WIN32_WINNT)
  150. const int max_iov_len = 64;
  151. # else
  152. const int max_iov_len = 16;
  153. # endif
  154. #else
  155. typedef int socket_type;
  156. const int invalid_socket = -1;
  157. const int socket_error_retval = -1;
  158. const int max_addr_v4_str_len = INET_ADDRSTRLEN;
  159. #if defined(INET6_ADDRSTRLEN)
  160. const int max_addr_v6_str_len = INET6_ADDRSTRLEN + 1 + IF_NAMESIZE;
  161. #else // defined(INET6_ADDRSTRLEN)
  162. const int max_addr_v6_str_len = 256;
  163. #endif // defined(INET6_ADDRSTRLEN)
  164. typedef sockaddr socket_addr_type;
  165. typedef in_addr in4_addr_type;
  166. # if defined(__hpux)
  167. // HP-UX doesn't provide ip_mreq when _XOPEN_SOURCE_EXTENDED is defined.
  168. struct in4_mreq_type
  169. {
  170. struct in_addr imr_multiaddr;
  171. struct in_addr imr_interface;
  172. };
  173. # else
  174. typedef ip_mreq in4_mreq_type;
  175. # endif
  176. typedef sockaddr_in sockaddr_in4_type;
  177. typedef in6_addr in6_addr_type;
  178. typedef ipv6_mreq in6_mreq_type;
  179. typedef sockaddr_in6 sockaddr_in6_type;
  180. typedef sockaddr_storage sockaddr_storage_type;
  181. typedef sockaddr_un sockaddr_un_type;
  182. typedef addrinfo addrinfo_type;
  183. typedef int ioctl_arg_type;
  184. typedef uint32_t u_long_type;
  185. typedef uint16_t u_short_type;
  186. const int shutdown_receive = SHUT_RD;
  187. const int shutdown_send = SHUT_WR;
  188. const int shutdown_both = SHUT_RDWR;
  189. const int message_peek = MSG_PEEK;
  190. const int message_out_of_band = MSG_OOB;
  191. const int message_do_not_route = MSG_DONTROUTE;
  192. # if defined(IOV_MAX)
  193. const int max_iov_len = IOV_MAX;
  194. # else
  195. // POSIX platforms are not required to define IOV_MAX.
  196. const int max_iov_len = 16;
  197. # endif
  198. #endif
  199. const int custom_socket_option_level = 0xA5100000;
  200. const int enable_connection_aborted_option = 1;
  201. const int always_fail_option = 2;
  202. } // namespace detail
  203. } // namespace asio
  204. } // namespace boost
  205. #include <boost/asio/detail/pop_options.hpp>
  206. #endif // BOOST_ASIO_DETAIL_SOCKET_TYPES_HPP