~ubuntu-branches/ubuntu/jaunty/asio/jaunty

« back to all changes in this revision

Viewing changes to include/asio/detail/socket_types.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Simon Richter
  • Date: 2007-09-07 11:10:41 UTC
  • Revision ID: james.westby@ubuntu.com-20070907111041-f0uwhs0llvzj9ah5
Tags: upstream-0.3.8~rc3
ImportĀ upstreamĀ versionĀ 0.3.8~rc3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// socket_types.hpp
 
3
// ~~~~~~~~~~~~~~~~
 
4
//
 
5
// Copyright (c) 2003-2007 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
 
 
11
#ifndef ASIO_DETAIL_SOCKET_TYPES_HPP
 
12
#define ASIO_DETAIL_SOCKET_TYPES_HPP
 
13
 
 
14
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
 
15
# pragma once
 
16
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
 
17
 
 
18
#include "asio/detail/push_options.hpp"
 
19
 
 
20
#include "asio/detail/push_options.hpp"
 
21
#include <boost/config.hpp>
 
22
#include "asio/detail/pop_options.hpp"
 
23
 
 
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=0x0500 (i.e. Windows 2000 target)")
 
33
#  else // defined(_MSC_VER) || defined(__BORLANDC__)
 
34
#   warning Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately
 
35
#   warning Assuming _WIN32_WINNT=0x0500 (i.e. Windows 2000 target)
 
36
#  endif // defined(_MSC_VER) || defined(__BORLANDC__)
 
37
#  define _WIN32_WINNT 0x0500
 
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_)
 
58
#   define _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)
 
72
#   define NOMINMAX 1
 
73
#  endif // !defined(NOMINMAX)
 
74
# endif // defined(__CYGWIN__)
 
75
# include <winsock2.h>
 
76
# include <ws2tcpip.h>
 
77
# include <mswsock.h>
 
78
# if defined(ASIO_WSPIAPI_H_DEFINED)
 
79
#  undef _WSPIAPI_H_
 
80
#  undef ASIO_WSPIAPI_H_DEFINED
 
81
# endif // defined(ASIO_WSPIAPI_H_DEFINED)
 
82
# if !defined(ASIO_NO_DEFAULT_LINKED_LIBS)
 
83
#  if defined(_MSC_VER) || defined(__BORLANDC__)
 
84
#   pragma comment(lib, "ws2_32.lib")
 
85
#   pragma comment(lib, "mswsock.lib")
 
86
#  endif // defined(_MSC_VER) || defined(__BORLANDC__)
 
87
# endif // !defined(ASIO_NO_DEFAULT_LINKED_LIBS)
 
88
# include "asio/detail/old_win_sdk_compat.hpp"
 
89
#else
 
90
# include <sys/ioctl.h>
 
91
# include <sys/poll.h>
 
92
# include <sys/types.h>
 
93
# include <sys/select.h>
 
94
# include <sys/socket.h>
 
95
# include <sys/uio.h>
 
96
# include <netinet/in.h>
 
97
# include <netinet/tcp.h>
 
98
# include <arpa/inet.h>
 
99
# include <netdb.h>
 
100
# include <net/if.h>
 
101
# if defined(__sun)
 
102
#  include <sys/filio.h>
 
103
#  include <sys/sockio.h>
 
104
# endif
 
105
#endif
 
106
#include "asio/detail/pop_options.hpp"
 
107
 
 
108
namespace asio {
 
109
namespace detail {
 
110
 
 
111
#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
 
112
typedef SOCKET socket_type;
 
113
const SOCKET invalid_socket = INVALID_SOCKET;
 
114
const int socket_error_retval = SOCKET_ERROR;
 
115
const int max_addr_v4_str_len = 256;
 
116
const int max_addr_v6_str_len = 256;
 
117
typedef sockaddr socket_addr_type;
 
118
typedef int socket_addr_len_type;
 
119
typedef in_addr in4_addr_type;
 
120
typedef ip_mreq in4_mreq_type;
 
121
typedef sockaddr_in sockaddr_in4_type;
 
122
# if defined(ASIO_HAS_OLD_WIN_SDK)
 
123
typedef in6_addr_emulation in6_addr_type;
 
124
typedef ipv6_mreq_emulation in6_mreq_type;
 
125
typedef sockaddr_in6_emulation sockaddr_in6_type;
 
126
typedef sockaddr_storage_emulation sockaddr_storage_type;
 
127
typedef addrinfo_emulation addrinfo_type;
 
128
# else
 
129
typedef in6_addr in6_addr_type;
 
130
typedef ipv6_mreq in6_mreq_type;
 
131
typedef sockaddr_in6 sockaddr_in6_type;
 
132
typedef sockaddr_storage sockaddr_storage_type;
 
133
typedef addrinfo addrinfo_type;
 
134
# endif
 
135
typedef unsigned long ioctl_arg_type;
 
136
typedef u_long u_long_type;
 
137
typedef u_short u_short_type;
 
138
const int shutdown_receive = SD_RECEIVE;
 
139
const int shutdown_send = SD_SEND;
 
140
const int shutdown_both = SD_BOTH;
 
141
const int message_peek = MSG_PEEK;
 
142
const int message_out_of_band = MSG_OOB;
 
143
const int message_do_not_route = MSG_DONTROUTE;
 
144
#else
 
145
typedef int socket_type;
 
146
const int invalid_socket = -1;
 
147
const int socket_error_retval = -1;
 
148
const int max_addr_v4_str_len = INET_ADDRSTRLEN;
 
149
const int max_addr_v6_str_len = INET6_ADDRSTRLEN + 1 + IF_NAMESIZE;
 
150
typedef sockaddr socket_addr_type;
 
151
typedef socklen_t socket_addr_len_type;
 
152
typedef in_addr in4_addr_type;
 
153
typedef ip_mreq in4_mreq_type;
 
154
typedef sockaddr_in sockaddr_in4_type;
 
155
typedef in6_addr in6_addr_type;
 
156
typedef ipv6_mreq in6_mreq_type;
 
157
typedef sockaddr_in6 sockaddr_in6_type;
 
158
typedef sockaddr_storage sockaddr_storage_type;
 
159
typedef addrinfo addrinfo_type;
 
160
typedef int ioctl_arg_type;
 
161
typedef uint32_t u_long_type;
 
162
typedef uint16_t u_short_type;
 
163
const int shutdown_receive = SHUT_RD;
 
164
const int shutdown_send = SHUT_WR;
 
165
const int shutdown_both = SHUT_RDWR;
 
166
const int message_peek = MSG_PEEK;
 
167
const int message_out_of_band = MSG_OOB;
 
168
const int message_do_not_route = MSG_DONTROUTE;
 
169
#endif
 
170
const int custom_socket_option_level = 0xA5100000;
 
171
const int enable_connection_aborted_option = 1;
 
172
const int always_fail_option = 2;
 
173
 
 
174
} // namespace detail
 
175
} // namespace asio
 
176
 
 
177
#include "asio/detail/pop_options.hpp"
 
178
 
 
179
#endif // ASIO_DETAIL_SOCKET_TYPES_HPP