00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef ASIO_DETAIL_SOCKET_TYPES_HPP
00012 #define ASIO_DETAIL_SOCKET_TYPES_HPP
00013
00014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
00015 # pragma once
00016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
00017
00018 #include "asio/detail/push_options.hpp"
00019
00020 #include "asio/detail/push_options.hpp"
00021 #include <boost/config.hpp>
00022 #include "asio/detail/pop_options.hpp"
00023
00024 #include "asio/detail/push_options.hpp"
00025 #if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
00026 # if defined(_WINSOCKAPI_) && !defined(_WINSOCK2API_)
00027 # error WinSock.h has already been included
00028 # endif // defined(_WINSOCKAPI_) && !defined(_WINSOCK2API_)
00029 # if !defined(_WIN32_WINNT) && !defined(_WIN32_WINDOWS)
00030 # if defined(_MSC_VER) || defined(__BORLANDC__)
00031 # pragma message("Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately")
00032 # pragma message("Assuming _WIN32_WINNT=0x0500 (i.e. Windows 2000 target)")
00033 # else // defined(_MSC_VER) || defined(__BORLANDC__)
00034 # warning Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately
00035 # warning Assuming _WIN32_WINNT=0x0500 (i.e. Windows 2000 target)
00036 # endif // defined(_MSC_VER) || defined(__BORLANDC__)
00037 # define _WIN32_WINNT 0x0500
00038 # endif // !defined(_WIN32_WINNT) && !defined(_WIN32_WINDOWS)
00039 # if defined(_MSC_VER)
00040 # if defined(_WIN32) && !defined(WIN32)
00041 # if !defined(_WINSOCK2API_)
00042 # define WIN32 // Needed for correct types in winsock2.h
00043 # else // !defined(_WINSOCK2API_)
00044 # error Please define the macro WIN32 in your compiler options
00045 # endif // !defined(_WINSOCK2API_)
00046 # endif // defined(_WIN32) && !defined(WIN32)
00047 # endif // defined(_MSC_VER)
00048 # if defined(__BORLANDC__)
00049 # include <stdlib.h>
00050 # if defined(__WIN32__) && !defined(WIN32)
00051 # if !defined(_WINSOCK2API_)
00052 # define WIN32 // Needed for correct types in winsock2.h
00053 # else // !defined(_WINSOCK2API_)
00054 # error Please define the macro WIN32 in your compiler options
00055 # endif // !defined(_WINSOCK2API_)
00056 # endif // defined(__WIN32__) && !defined(WIN32)
00057 # if !defined(_WSPIAPI_H_)
00058 # define _WSPIAPI_H_
00059 # define ASIO_WSPIAPI_H_DEFINED
00060 # endif // !defined(_WSPIAPI_H_)
00061 # endif // defined(__BORLANDC__)
00062 # if !defined(ASIO_NO_WIN32_LEAN_AND_MEAN)
00063 # if !defined(WIN32_LEAN_AND_MEAN)
00064 # define WIN32_LEAN_AND_MEAN
00065 # endif // !defined(WIN32_LEAN_AND_MEAN)
00066 # endif // !defined(ASIO_NO_WIN32_LEAN_AND_MEAN)
00067 # if defined(__CYGWIN__)
00068 # if !defined(__USE_W32_SOCKETS)
00069 # error You must add -D__USE_W32_SOCKETS to your compiler options.
00070 # endif // !defined(__USE_W32_SOCKETS)
00071 # if !defined(NOMINMAX)
00072 # define NOMINMAX 1
00073 # endif // !defined(NOMINMAX)
00074 # endif // defined(__CYGWIN__)
00075 # include <winsock2.h>
00076 # include <ws2tcpip.h>
00077 # include <mswsock.h>
00078 # if defined(ASIO_WSPIAPI_H_DEFINED)
00079 # undef _WSPIAPI_H_
00080 # undef ASIO_WSPIAPI_H_DEFINED
00081 # endif // defined(ASIO_WSPIAPI_H_DEFINED)
00082 # if !defined(ASIO_NO_DEFAULT_LINKED_LIBS)
00083 # if defined(_MSC_VER) || defined(__BORLANDC__)
00084 # pragma comment(lib, "ws2_32.lib")
00085 # pragma comment(lib, "mswsock.lib")
00086 # endif // defined(_MSC_VER) || defined(__BORLANDC__)
00087 # endif // !defined(ASIO_NO_DEFAULT_LINKED_LIBS)
00088 # include "asio/detail/old_win_sdk_compat.hpp"
00089 #else
00090 # include <sys/ioctl.h>
00091 # include <sys/poll.h>
00092 # include <sys/types.h>
00093 # include <sys/select.h>
00094 # include <sys/socket.h>
00095 # include <sys/uio.h>
00096 # include <netinet/in.h>
00097 # include <netinet/tcp.h>
00098 # include <arpa/inet.h>
00099 # include <netdb.h>
00100 # include <net/if.h>
00101 # if defined(__sun)
00102 # include <sys/filio.h>
00103 # include <sys/sockio.h>
00104 # endif
00105 #endif
00106 #include "asio/detail/pop_options.hpp"
00107
00108 namespace asio {
00109 namespace detail {
00110
00111 #if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
00112 typedef SOCKET socket_type;
00113 const SOCKET invalid_socket = INVALID_SOCKET;
00114 const int socket_error_retval = SOCKET_ERROR;
00115 const int max_addr_v4_str_len = 256;
00116 const int max_addr_v6_str_len = 256;
00117 typedef sockaddr socket_addr_type;
00118 typedef int socket_addr_len_type;
00119 typedef in_addr in4_addr_type;
00120 typedef ip_mreq in4_mreq_type;
00121 typedef sockaddr_in sockaddr_in4_type;
00122 # if defined(ASIO_HAS_OLD_WIN_SDK)
00123 typedef in6_addr_emulation in6_addr_type;
00124 typedef ipv6_mreq_emulation in6_mreq_type;
00125 typedef sockaddr_in6_emulation sockaddr_in6_type;
00126 typedef sockaddr_storage_emulation sockaddr_storage_type;
00127 typedef addrinfo_emulation addrinfo_type;
00128 # else
00129 typedef in6_addr in6_addr_type;
00130 typedef ipv6_mreq in6_mreq_type;
00131 typedef sockaddr_in6 sockaddr_in6_type;
00132 typedef sockaddr_storage sockaddr_storage_type;
00133 typedef addrinfo addrinfo_type;
00134 # endif
00135 typedef unsigned long ioctl_arg_type;
00136 typedef u_long u_long_type;
00137 typedef u_short u_short_type;
00138 const int shutdown_receive = SD_RECEIVE;
00139 const int shutdown_send = SD_SEND;
00140 const int shutdown_both = SD_BOTH;
00141 const int message_peek = MSG_PEEK;
00142 const int message_out_of_band = MSG_OOB;
00143 const int message_do_not_route = MSG_DONTROUTE;
00144 #else
00145 typedef int socket_type;
00146 const int invalid_socket = -1;
00147 const int socket_error_retval = -1;
00148 const int max_addr_v4_str_len = INET_ADDRSTRLEN;
00149 const int max_addr_v6_str_len = INET6_ADDRSTRLEN + 1 + IF_NAMESIZE;
00150 typedef sockaddr socket_addr_type;
00151 typedef socklen_t socket_addr_len_type;
00152 typedef in_addr in4_addr_type;
00153 typedef ip_mreq in4_mreq_type;
00154 typedef sockaddr_in sockaddr_in4_type;
00155 typedef in6_addr in6_addr_type;
00156 typedef ipv6_mreq in6_mreq_type;
00157 typedef sockaddr_in6 sockaddr_in6_type;
00158 typedef sockaddr_storage sockaddr_storage_type;
00159 typedef addrinfo addrinfo_type;
00160 typedef int ioctl_arg_type;
00161 typedef uint32_t u_long_type;
00162 typedef uint16_t u_short_type;
00163 const int shutdown_receive = SHUT_RD;
00164 const int shutdown_send = SHUT_WR;
00165 const int shutdown_both = SHUT_RDWR;
00166 const int message_peek = MSG_PEEK;
00167 const int message_out_of_band = MSG_OOB;
00168 const int message_do_not_route = MSG_DONTROUTE;
00169 #endif
00170 const int custom_socket_option_level = 0xA5100000;
00171 const int enable_connection_aborted_option = 1;
00172
00173 }
00174 }
00175
00176 #include "asio/detail/pop_options.hpp"
00177
00178 #endif // ASIO_DETAIL_SOCKET_TYPES_HPP