Realistic 3D camera system
3D camera system components
socket_ops.hpp
Go to the documentation of this file.
1 //
2 // detail/socket_ops.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2015 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_OPS_HPP
12 #define ASIO_DETAIL_SOCKET_OPS_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/config.hpp"
19 
20 #include "asio/error_code.hpp"
23 #include "asio/detail/weak_ptr.hpp"
24 
26 
27 namespace asio {
28 namespace detail {
29 namespace socket_ops {
30 
31 // Socket state bits.
32 enum
33 {
34  // The user wants a non-blocking socket.
36 
37  // The socket has been set non-blocking.
39 
40  // Helper "state" used to determine whether the socket is non-blocking.
42 
43  // User wants connection_aborted errors, which are disabled by default.
45 
46  // The user set the linger option. Needs to be checked when closing.
48 
49  // The socket is stream-oriented.
51 
52  // The socket is datagram-oriented.
54 
55  // The socket may have been dup()-ed.
57 };
58 
59 typedef unsigned char state_type;
60 
61 struct noop_deleter { void operator()(void*) {} };
62 typedef shared_ptr<void> shared_cancel_token_type;
63 typedef weak_ptr<void> weak_cancel_token_type;
64 
65 #if !defined(ASIO_WINDOWS_RUNTIME)
66 
68  std::size_t* addrlen, asio::error_code& ec);
69 
71  state_type state, socket_addr_type* addr,
72  std::size_t* addrlen, asio::error_code& ec);
73 
74 #if defined(ASIO_HAS_IOCP)
75 
76 ASIO_DECL void complete_iocp_accept(socket_type s,
77  void* output_buffer, DWORD address_length,
78  socket_addr_type* addr, std::size_t* addrlen,
79  socket_type new_socket, asio::error_code& ec);
80 
81 #else // defined(ASIO_HAS_IOCP)
82 
84  state_type state, socket_addr_type* addr, std::size_t* addrlen,
85  asio::error_code& ec, socket_type& new_socket);
86 
87 #endif // defined(ASIO_HAS_IOCP)
88 
90  std::size_t addrlen, asio::error_code& ec);
91 
92 ASIO_DECL int close(socket_type s, state_type& state,
93  bool destruction, asio::error_code& ec);
94 
96  state_type& state, bool value, asio::error_code& ec);
97 
99  state_type& state, bool value, asio::error_code& ec);
100 
102  int what, asio::error_code& ec);
103 
105  std::size_t addrlen, asio::error_code& ec);
106 
108  std::size_t addrlen, asio::error_code& ec);
109 
110 #if defined(ASIO_HAS_IOCP)
111 
112 ASIO_DECL void complete_iocp_connect(socket_type s,
113  asio::error_code& ec);
114 
115 #endif // defined(ASIO_HAS_IOCP)
116 
118  asio::error_code& ec);
119 
120 ASIO_DECL int socketpair(int af, int type, int protocol,
121  socket_type sv[2], asio::error_code& ec);
122 
124 
126 
128  int backlog, asio::error_code& ec);
129 
130 #if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
131 typedef WSABUF buf;
132 #else // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
133 typedef iovec buf;
134 #endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
135 
136 ASIO_DECL void init_buf(buf& b, void* data, size_t size);
137 
138 ASIO_DECL void init_buf(buf& b, const void* data, size_t size);
139 
141  size_t count, int flags, asio::error_code& ec);
142 
143 ASIO_DECL size_t sync_recv(socket_type s, state_type state, buf* bufs,
144  size_t count, int flags, bool all_empty, asio::error_code& ec);
145 
146 #if defined(ASIO_HAS_IOCP)
147 
148 ASIO_DECL void complete_iocp_recv(state_type state,
149  const weak_cancel_token_type& cancel_token, bool all_empty,
150  asio::error_code& ec, size_t bytes_transferred);
151 
152 #else // defined(ASIO_HAS_IOCP)
153 
155  buf* bufs, size_t count, int flags, bool is_stream,
156  asio::error_code& ec, size_t& bytes_transferred);
157 
158 #endif // defined(ASIO_HAS_IOCP)
159 
161  size_t count, int flags, socket_addr_type* addr,
162  std::size_t* addrlen, asio::error_code& ec);
163 
164 ASIO_DECL size_t sync_recvfrom(socket_type s, state_type state,
165  buf* bufs, size_t count, int flags, socket_addr_type* addr,
166  std::size_t* addrlen, asio::error_code& ec);
167 
168 #if defined(ASIO_HAS_IOCP)
169 
170 ASIO_DECL void complete_iocp_recvfrom(
171  const weak_cancel_token_type& cancel_token,
172  asio::error_code& ec);
173 
174 #else // defined(ASIO_HAS_IOCP)
175 
177  buf* bufs, size_t count, int flags,
178  socket_addr_type* addr, std::size_t* addrlen,
179  asio::error_code& ec, size_t& bytes_transferred);
180 
181 #endif // defined(ASIO_HAS_IOCP)
182 
184  size_t count, int in_flags, int& out_flags,
185  asio::error_code& ec);
186 
187 ASIO_DECL size_t sync_recvmsg(socket_type s, state_type state,
188  buf* bufs, size_t count, int in_flags, int& out_flags,
189  asio::error_code& ec);
190 
191 #if defined(ASIO_HAS_IOCP)
192 
193 ASIO_DECL void complete_iocp_recvmsg(
194  const weak_cancel_token_type& cancel_token,
195  asio::error_code& ec);
196 
197 #else // defined(ASIO_HAS_IOCP)
198 
200  buf* bufs, size_t count, int in_flags, int& out_flags,
201  asio::error_code& ec, size_t& bytes_transferred);
202 
203 #endif // defined(ASIO_HAS_IOCP)
204 
205 ASIO_DECL signed_size_type send(socket_type s, const buf* bufs,
206  size_t count, int flags, asio::error_code& ec);
207 
208 ASIO_DECL size_t sync_send(socket_type s, state_type state,
209  const buf* bufs, size_t count, int flags,
210  bool all_empty, asio::error_code& ec);
211 
212 #if defined(ASIO_HAS_IOCP)
213 
214 ASIO_DECL void complete_iocp_send(
215  const weak_cancel_token_type& cancel_token,
216  asio::error_code& ec);
217 
218 #else // defined(ASIO_HAS_IOCP)
219 
221  const buf* bufs, size_t count, int flags,
222  asio::error_code& ec, size_t& bytes_transferred);
223 
224 #endif // defined(ASIO_HAS_IOCP)
225 
227  size_t count, int flags, const socket_addr_type* addr,
228  std::size_t addrlen, asio::error_code& ec);
229 
230 ASIO_DECL size_t sync_sendto(socket_type s, state_type state,
231  const buf* bufs, size_t count, int flags, const socket_addr_type* addr,
232  std::size_t addrlen, asio::error_code& ec);
233 
234 #if !defined(ASIO_HAS_IOCP)
235 
237  const buf* bufs, size_t count, int flags,
238  const socket_addr_type* addr, std::size_t addrlen,
239  asio::error_code& ec, size_t& bytes_transferred);
240 
241 #endif // !defined(ASIO_HAS_IOCP)
242 
243 ASIO_DECL socket_type socket(int af, int type, int protocol,
244  asio::error_code& ec);
245 
246 ASIO_DECL int setsockopt(socket_type s, state_type& state,
247  int level, int optname, const void* optval,
248  std::size_t optlen, asio::error_code& ec);
249 
250 ASIO_DECL int getsockopt(socket_type s, state_type state,
251  int level, int optname, void* optval,
252  size_t* optlen, asio::error_code& ec);
253 
255  std::size_t* addrlen, bool cached, asio::error_code& ec);
256 
258  std::size_t* addrlen, asio::error_code& ec);
259 
260 ASIO_DECL int ioctl(socket_type s, state_type& state,
261  int cmd, ioctl_arg_type* arg, asio::error_code& ec);
262 
263 ASIO_DECL int select(int nfds, fd_set* readfds, fd_set* writefds,
264  fd_set* exceptfds, timeval* timeout, asio::error_code& ec);
265 
267  state_type state, asio::error_code& ec);
268 
270  state_type state, asio::error_code& ec);
271 
273 
274 #endif // !defined(ASIO_WINDOWS_RUNTIME)
275 
276 ASIO_DECL const char* inet_ntop(int af, const void* src, char* dest,
277  size_t length, unsigned long scope_id, asio::error_code& ec);
278 
279 ASIO_DECL int inet_pton(int af, const char* src, void* dest,
280  unsigned long* scope_id, asio::error_code& ec);
281 
282 ASIO_DECL int gethostname(char* name,
283  int namelen, asio::error_code& ec);
284 
285 #if !defined(ASIO_WINDOWS_RUNTIME)
286 
287 ASIO_DECL asio::error_code getaddrinfo(const char* host,
288  const char* service, const addrinfo_type& hints,
289  addrinfo_type** result, asio::error_code& ec);
290 
292  const weak_cancel_token_type& cancel_token, const char* host,
293  const char* service, const addrinfo_type& hints,
294  addrinfo_type** result, asio::error_code& ec);
295 
297 
299  const socket_addr_type* addr, std::size_t addrlen,
300  char* host, std::size_t hostlen, char* serv,
301  std::size_t servlen, int flags, asio::error_code& ec);
302 
304  const socket_addr_type* addr, std::size_t addrlen,
305  char* host, std::size_t hostlen, char* serv,
306  std::size_t servlen, int sock_type, asio::error_code& ec);
307 
309  const weak_cancel_token_type& cancel_token,
310  const socket_addr_type* addr, std::size_t addrlen,
311  char* host, std::size_t hostlen, char* serv,
312  std::size_t servlen, int sock_type, asio::error_code& ec);
313 
314 #endif // !defined(ASIO_WINDOWS_RUNTIME)
315 
317 
319 
321 
323 
324 } // namespace socket_ops
325 } // namespace detail
326 } // namespace asio
327 
329 
330 #if defined(ASIO_HEADER_ONLY)
332 #endif // defined(ASIO_HEADER_ONLY)
333 
334 #endif // ASIO_DETAIL_SOCKET_OPS_HPP
int connect(socket_type s, const socket_addr_type *addr, std::size_t addrlen, asio::error_code &ec)
Definition: socket_ops.ipp:474
bool set_user_non_blocking(socket_type s, state_type &state, bool value, asio::error_code &ec)
Definition: socket_ops.ipp:360
signed_size_type recvmsg(socket_type s, buf *bufs, size_t count, int in_flags, int &out_flags, asio::error_code &ec)
const char * inet_ntop(int af, const void *src, char *dest, size_t length, unsigned long scope_id, asio::error_code &ec)
shared_ptr< void > shared_cancel_token_type
Definition: socket_ops.hpp:62
size_t sync_recv(socket_type s, state_type state, buf *bufs, size_t count, int flags, bool all_empty, asio::error_code &ec)
Definition: socket_ops.ipp:790
socket_type socket(int af, int type, int protocol, asio::error_code &ec)
SocketService & s
Definition: connect.hpp:521
int poll_connect(socket_type s, asio::error_code &ec)
bool sockatmark(socket_type s, asio::error_code &ec)
Definition: socket_ops.ipp:630
size_t sync_send(socket_type s, state_type state, const buf *bufs, size_t count, int flags, bool all_empty, asio::error_code &ec)
bool non_blocking_recv(socket_type s, buf *bufs, size_t count, int flags, bool is_stream, asio::error_code &ec, size_t &bytes_transferred)
Definition: socket_ops.ipp:865
int getsockopt(socket_type s, state_type state, int level, int optname, void *optval, size_t *optlen, asio::error_code &ec)
int getsockname(socket_type s, socket_addr_type *addr, std::size_t *addrlen, asio::error_code &ec)
signed_size_type recvfrom(socket_type s, buf *bufs, size_t count, int flags, socket_addr_type *addr, std::size_t *addrlen, asio::error_code &ec)
Definition: socket_ops.ipp:905
void init_buf(buf &b, void *data, size_t size)
Definition: socket_ops.ipp:716
bool non_blocking_send(socket_type s, const buf *bufs, size_t count, int flags, asio::error_code &ec, size_t &bytes_transferred)
int poll_read(socket_type s, state_type state, asio::error_code &ec)
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, timeval *timeout, asio::error_code &ec)
u_short_type host_to_network_short(u_short_type value)
int listen(socket_type s, int backlog, asio::error_code &ec)
Definition: socket_ops.ipp:684
sockaddr socket_addr_type
size_t sync_sendto(socket_type s, state_type state, const buf *bufs, size_t count, int flags, const socket_addr_type *addr, std::size_t addrlen, asio::error_code &ec)
asio::basic_streambuf< Allocator > & b
Definition: read.hpp:702
addrinfo addrinfo_type
weak_ptr< void > weak_cancel_token_type
Definition: socket_ops.hpp:63
int setsockopt(socket_type s, state_type &state, int level, int optname, const void *optval, std::size_t optlen, asio::error_code &ec)
int ioctl(socket_type s, state_type &state, int cmd, ioctl_arg_type *arg, asio::error_code &ec)
int inet_pton(int af, const char *src, void *dest, unsigned long *scope_id, asio::error_code &ec)
signed_size_type send(socket_type s, const buf *bufs, size_t count, int flags, asio::error_code &ec)
asio::error_code background_getaddrinfo(const weak_cancel_token_type &cancel_token, const char *host, const char *service, const addrinfo_type &hints, addrinfo_type **result, asio::error_code &ec)
int socketpair(int af, int type, int protocol, socket_type sv[2], asio::error_code &ec)
Definition: socket_ops.ipp:611
u_long_type host_to_network_long(u_long_type value)
int gethostname(char *name, int namelen, asio::error_code &ec)
bool non_blocking_recvmsg(socket_type s, buf *bufs, size_t count, int in_flags, int &out_flags, asio::error_code &ec, size_t &bytes_transferred)
bool non_blocking_sendto(socket_type s, const buf *bufs, size_t count, int flags, const socket_addr_type *addr, std::size_t addrlen, asio::error_code &ec, size_t &bytes_transferred)
int poll_write(socket_type s, state_type state, asio::error_code &ec)
asio::error_code getnameinfo(const socket_addr_type *addr, std::size_t addrlen, char *host, std::size_t hostlen, char *serv, std::size_t servlen, int flags, asio::error_code &ec)
unsigned char state_type
Definition: socket_ops.hpp:59
size_t available(socket_type s, asio::error_code &ec)
Definition: socket_ops.ipp:660
void freeaddrinfo(addrinfo_type *ai)
int bind(socket_type s, const socket_addr_type *addr, std::size_t addrlen, asio::error_code &ec)
Definition: socket_ops.ipp:278
signed_size_type sendto(socket_type s, const buf *bufs, size_t count, int flags, const socket_addr_type *addr, std::size_t addrlen, asio::error_code &ec)
Class to represent an error code value.
Definition: error_code.hpp:80
size_t sync_recvmsg(socket_type s, state_type state, buf *bufs, size_t count, int in_flags, int &out_flags, asio::error_code &ec)
#define ASIO_DECL
Definition: config.hpp:43
u_short_type network_to_host_short(u_short_type value)
socket_type accept(socket_type s, socket_addr_type *addr, std::size_t *addrlen, asio::error_code &ec)
Definition: socket_ops.ipp:101
void sync_connect(socket_type s, const socket_addr_type *addr, std::size_t addrlen, asio::error_code &ec)
Definition: socket_ops.ipp:495
asio::error_code sync_getnameinfo(const socket_addr_type *addr, std::size_t addrlen, char *host, std::size_t hostlen, char *serv, std::size_t servlen, int sock_type, asio::error_code &ec)
int getpeername(socket_type s, socket_addr_type *addr, std::size_t *addrlen, bool cached, asio::error_code &ec)
int shutdown(socket_type s, int what, asio::error_code &ec)
Definition: socket_ops.ipp:452
signed_size_type recv(socket_type s, buf *bufs, size_t count, int flags, asio::error_code &ec)
Definition: socket_ops.ipp:760
size_t sync_recvfrom(socket_type s, state_type state, buf *bufs, size_t count, int flags, socket_addr_type *addr, std::size_t *addrlen, asio::error_code &ec)
Definition: socket_ops.ipp:941
bool non_blocking_connect(socket_type s, asio::error_code &ec)
Definition: socket_ops.ipp:559
bool non_blocking_recvfrom(socket_type s, buf *bufs, size_t count, int flags, socket_addr_type *addr, std::size_t *addrlen, asio::error_code &ec, size_t &bytes_transferred)
Definition: socket_ops.ipp:996
socket_type sync_accept(socket_type s, state_type state, socket_addr_type *addr, std::size_t *addrlen, asio::error_code &ec)
Definition: socket_ops.ipp:132
bool non_blocking_accept(socket_type s, state_type state, socket_addr_type *addr, std::size_t *addrlen, asio::error_code &ec, socket_type &new_socket)
Definition: socket_ops.ipp:223
u_long_type network_to_host_long(u_long_type value)
uint32_t u_long_type
bool set_internal_non_blocking(socket_type s, state_type &state, bool value, asio::error_code &ec)
Definition: socket_ops.ipp:404
int close(socket_type s, state_type &state, bool destruction, asio::error_code &ec)
Definition: socket_ops.ipp:295
asio::error_code getaddrinfo(const char *host, const char *service, const addrinfo_type &hints, addrinfo_type **result, asio::error_code &ec)
asio::error_code background_getnameinfo(const weak_cancel_token_type &cancel_token, const socket_addr_type *addr, std::size_t addrlen, char *host, std::size_t hostlen, char *serv, std::size_t servlen, int sock_type, asio::error_code &ec)
uint16_t u_short_type