Realistic 3D camera system
3D camera system components
null_socket_service.hpp
Go to the documentation of this file.
1 //
2 // detail/null_socket_service.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_NULL_SOCKET_SERVICE_HPP
12 #define ASIO_DETAIL_NULL_SOCKET_SERVICE_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 #if defined(ASIO_WINDOWS_RUNTIME)
21 
22 #include "asio/buffer.hpp"
23 #include "asio/error.hpp"
24 #include "asio/io_service.hpp"
25 #include "asio/socket_base.hpp"
27 
29 
30 namespace asio {
31 namespace detail {
32 
33 template <typename Protocol>
34 class null_socket_service
35 {
36 public:
37  // The protocol type.
38  typedef Protocol protocol_type;
39 
40  // The endpoint type.
41  typedef typename Protocol::endpoint endpoint_type;
42 
43  // The native type of a socket.
44  typedef int native_handle_type;
45 
46  // The implementation type of the socket.
47  struct implementation_type
48  {
49  };
50 
51  // Constructor.
52  null_socket_service(asio::io_service& io_service)
53  : io_service_(io_service)
54  {
55  }
56 
57  // Destroy all user-defined handler objects owned by the service.
58  void shutdown_service()
59  {
60  }
61 
62  // Construct a new socket implementation.
63  void construct(implementation_type&)
64  {
65  }
66 
67  // Move-construct a new socket implementation.
68  void move_construct(implementation_type&, implementation_type&)
69  {
70  }
71 
72  // Move-assign from another socket implementation.
73  void move_assign(implementation_type&,
74  null_socket_service&, implementation_type&)
75  {
76  }
77 
78  // Move-construct a new socket implementation from another protocol type.
79  template <typename Protocol1>
80  void converting_move_construct(implementation_type&,
81  typename null_socket_service<Protocol1>::implementation_type&)
82  {
83  }
84 
85  // Destroy a socket implementation.
86  void destroy(implementation_type&)
87  {
88  }
89 
90  // Open a new socket implementation.
91  asio::error_code open(implementation_type&,
92  const protocol_type&, asio::error_code& ec)
93  {
95  return ec;
96  }
97 
98  // Assign a native socket to a socket implementation.
99  asio::error_code assign(implementation_type&, const protocol_type&,
100  const native_handle_type&, asio::error_code& ec)
101  {
103  return ec;
104  }
105 
106  // Determine whether the socket is open.
107  bool is_open(const implementation_type&) const
108  {
109  return false;
110  }
111 
112  // Destroy a socket implementation.
113  asio::error_code close(implementation_type&,
114  asio::error_code& ec)
115  {
117  return ec;
118  }
119 
120  // Get the native socket representation.
121  native_handle_type native_handle(implementation_type&)
122  {
123  return 0;
124  }
125 
126  // Cancel all operations associated with the socket.
127  asio::error_code cancel(implementation_type&,
128  asio::error_code& ec)
129  {
131  return ec;
132  }
133 
134  // Determine whether the socket is at the out-of-band data mark.
135  bool at_mark(const implementation_type&,
136  asio::error_code& ec) const
137  {
139  return false;
140  }
141 
142  // Determine the number of bytes available for reading.
143  std::size_t available(const implementation_type&,
144  asio::error_code& ec) const
145  {
147  return 0;
148  }
149 
150  // Place the socket into the state where it will listen for new connections.
151  asio::error_code listen(implementation_type&,
152  int, asio::error_code& ec)
153  {
155  return ec;
156  }
157 
158  // Perform an IO control command on the socket.
159  template <typename IO_Control_Command>
160  asio::error_code io_control(implementation_type&,
161  IO_Control_Command&, asio::error_code& ec)
162  {
164  return ec;
165  }
166 
167  // Gets the non-blocking mode of the socket.
168  bool non_blocking(const implementation_type&) const
169  {
170  return false;
171  }
172 
173  // Sets the non-blocking mode of the socket.
174  asio::error_code non_blocking(implementation_type&,
175  bool, asio::error_code& ec)
176  {
178  return ec;
179  }
180 
181  // Gets the non-blocking mode of the native socket implementation.
182  bool native_non_blocking(const implementation_type&) const
183  {
184  return false;
185  }
186 
187  // Sets the non-blocking mode of the native socket implementation.
188  asio::error_code native_non_blocking(implementation_type&,
189  bool, asio::error_code& ec)
190  {
192  return ec;
193  }
194 
195  // Disable sends or receives on the socket.
196  asio::error_code shutdown(implementation_type&,
198  {
200  return ec;
201  }
202 
203  // Bind the socket to the specified local endpoint.
204  asio::error_code bind(implementation_type&,
205  const endpoint_type&, asio::error_code& ec)
206  {
208  return ec;
209  }
210 
211  // Set a socket option.
212  template <typename Option>
213  asio::error_code set_option(implementation_type&,
214  const Option&, asio::error_code& ec)
215  {
217  return ec;
218  }
219 
220  // Set a socket option.
221  template <typename Option>
222  asio::error_code get_option(const implementation_type&,
223  Option&, asio::error_code& ec) const
224  {
226  return ec;
227  }
228 
229  // Get the local endpoint.
230  endpoint_type local_endpoint(const implementation_type&,
231  asio::error_code& ec) const
232  {
234  return endpoint_type();
235  }
236 
237  // Get the remote endpoint.
238  endpoint_type remote_endpoint(const implementation_type&,
239  asio::error_code& ec) const
240  {
242  return endpoint_type();
243  }
244 
245  // Send the given data to the peer.
246  template <typename ConstBufferSequence>
247  std::size_t send(implementation_type&, const ConstBufferSequence&,
249  {
251  return 0;
252  }
253 
254  // Wait until data can be sent without blocking.
255  std::size_t send(implementation_type&, const null_buffers&,
257  {
259  return 0;
260  }
261 
262  // Start an asynchronous send. The data being sent must be valid for the
263  // lifetime of the asynchronous operation.
264  template <typename ConstBufferSequence, typename Handler>
265  void async_send(implementation_type&, const ConstBufferSequence&,
266  socket_base::message_flags, Handler& handler)
267  {
269  const std::size_t bytes_transferred = 0;
270  io_service_.post(detail::bind_handler(handler, ec, bytes_transferred));
271  }
272 
273  // Start an asynchronous wait until data can be sent without blocking.
274  template <typename Handler>
275  void async_send(implementation_type&, const null_buffers&,
276  socket_base::message_flags, Handler& handler)
277  {
279  const std::size_t bytes_transferred = 0;
280  io_service_.post(detail::bind_handler(handler, ec, bytes_transferred));
281  }
282 
283  // Receive some data from the peer. Returns the number of bytes received.
284  template <typename MutableBufferSequence>
285  std::size_t receive(implementation_type&, const MutableBufferSequence&,
287  {
289  return 0;
290  }
291 
292  // Wait until data can be received without blocking.
293  std::size_t receive(implementation_type&, const null_buffers&,
295  {
297  return 0;
298  }
299 
300  // Start an asynchronous receive. The buffer for the data being received
301  // must be valid for the lifetime of the asynchronous operation.
302  template <typename MutableBufferSequence, typename Handler>
303  void async_receive(implementation_type&, const MutableBufferSequence&,
304  socket_base::message_flags, Handler& handler)
305  {
307  const std::size_t bytes_transferred = 0;
308  io_service_.post(detail::bind_handler(handler, ec, bytes_transferred));
309  }
310 
311  // Wait until data can be received without blocking.
312  template <typename Handler>
313  void async_receive(implementation_type&, const null_buffers&,
314  socket_base::message_flags, Handler& handler)
315  {
317  const std::size_t bytes_transferred = 0;
318  io_service_.post(detail::bind_handler(handler, ec, bytes_transferred));
319  }
320 
321  // Receive some data with associated flags. Returns the number of bytes
322  // received.
323  template <typename MutableBufferSequence>
324  std::size_t receive_with_flags(implementation_type&,
325  const MutableBufferSequence&, socket_base::message_flags,
327  {
329  return 0;
330  }
331 
332  // Wait until data can be received without blocking.
333  std::size_t receive_with_flags(implementation_type&,
334  const null_buffers&, socket_base::message_flags,
336  {
338  return 0;
339  }
340 
341  // Start an asynchronous receive. The buffer for the data being received
342  // must be valid for the lifetime of the asynchronous operation.
343  template <typename MutableBufferSequence, typename Handler>
344  void async_receive_with_flags(implementation_type&,
345  const MutableBufferSequence&, socket_base::message_flags,
346  socket_base::message_flags&, Handler& handler)
347  {
349  const std::size_t bytes_transferred = 0;
350  io_service_.post(detail::bind_handler(handler, ec, bytes_transferred));
351  }
352 
353  // Wait until data can be received without blocking.
354  template <typename Handler>
355  void async_receive_with_flags(implementation_type&,
356  const null_buffers&, socket_base::message_flags,
357  socket_base::message_flags&, Handler& handler)
358  {
360  const std::size_t bytes_transferred = 0;
361  io_service_.post(detail::bind_handler(handler, ec, bytes_transferred));
362  }
363 
364  // Send a datagram to the specified endpoint. Returns the number of bytes
365  // sent.
366  template <typename ConstBufferSequence>
367  std::size_t send_to(implementation_type&, const ConstBufferSequence&,
368  const endpoint_type&, socket_base::message_flags,
369  asio::error_code& ec)
370  {
372  return 0;
373  }
374 
375  // Wait until data can be sent without blocking.
376  std::size_t send_to(implementation_type&, const null_buffers&,
377  const endpoint_type&, socket_base::message_flags,
378  asio::error_code& ec)
379  {
381  return 0;
382  }
383 
384  // Start an asynchronous send. The data being sent must be valid for the
385  // lifetime of the asynchronous operation.
386  template <typename ConstBufferSequence, typename Handler>
387  void async_send_to(implementation_type&, const ConstBufferSequence&,
388  const endpoint_type&, socket_base::message_flags,
389  Handler& handler)
390  {
392  const std::size_t bytes_transferred = 0;
393  io_service_.post(detail::bind_handler(handler, ec, bytes_transferred));
394  }
395 
396  // Start an asynchronous wait until data can be sent without blocking.
397  template <typename Handler>
398  void async_send_to(implementation_type&, const null_buffers&,
399  const endpoint_type&, socket_base::message_flags, Handler& handler)
400  {
402  const std::size_t bytes_transferred = 0;
403  io_service_.post(detail::bind_handler(handler, ec, bytes_transferred));
404  }
405 
406  // Receive a datagram with the endpoint of the sender. Returns the number of
407  // bytes received.
408  template <typename MutableBufferSequence>
409  std::size_t receive_from(implementation_type&, const MutableBufferSequence&,
410  endpoint_type&, socket_base::message_flags,
411  asio::error_code& ec)
412  {
414  return 0;
415  }
416 
417  // Wait until data can be received without blocking.
418  std::size_t receive_from(implementation_type&, const null_buffers&,
419  endpoint_type&, socket_base::message_flags,
420  asio::error_code& ec)
421  {
423  return 0;
424  }
425 
426  // Start an asynchronous receive. The buffer for the data being received and
427  // the sender_endpoint object must both be valid for the lifetime of the
428  // asynchronous operation.
429  template <typename MutableBufferSequence, typename Handler>
430  void async_receive_from(implementation_type&,
431  const MutableBufferSequence&, endpoint_type&,
432  socket_base::message_flags, Handler& handler)
433  {
435  const std::size_t bytes_transferred = 0;
436  io_service_.post(detail::bind_handler(handler, ec, bytes_transferred));
437  }
438 
439  // Wait until data can be received without blocking.
440  template <typename Handler>
441  void async_receive_from(implementation_type&,
442  const null_buffers&, endpoint_type&,
443  socket_base::message_flags, Handler& handler)
444  {
446  const std::size_t bytes_transferred = 0;
447  io_service_.post(detail::bind_handler(handler, ec, bytes_transferred));
448  }
449 
450  // Accept a new connection.
451  template <typename Socket>
452  asio::error_code accept(implementation_type&,
453  Socket&, endpoint_type*, asio::error_code& ec)
454  {
456  return ec;
457  }
458 
459  // Start an asynchronous accept. The peer and peer_endpoint objects
460  // must be valid until the accept's handler is invoked.
461  template <typename Socket, typename Handler>
462  void async_accept(implementation_type&, Socket&,
463  endpoint_type*, Handler& handler)
464  {
466  io_service_.post(detail::bind_handler(handler, ec));
467  }
468 
469  // Connect the socket to the specified endpoint.
470  asio::error_code connect(implementation_type&,
471  const endpoint_type&, asio::error_code& ec)
472  {
474  return ec;
475  }
476 
477  // Start an asynchronous connect.
478  template <typename Handler>
479  void async_connect(implementation_type&,
480  const endpoint_type&, Handler& handler)
481  {
483  io_service_.post(detail::bind_handler(handler, ec));
484  }
485 
486 private:
487  asio::io_service& io_service_;
488 };
489 
490 } // namespace detail
491 } // namespace asio
492 
494 
495 #endif // defined(ASIO_WINDOWS_RUNTIME)
496 
497 #endif // ASIO_DETAIL_NULL_SOCKET_SERVICE_HPP
int message_flags
Bitmask type for flags that can be passed to send and receive operations.
Definition: socket_base.hpp:53
Provides core I/O functionality.
Definition: io_service.hpp:184
Iterator connect(basic_socket< Protocol, SocketService > &s, Iterator begin)
Establishes a socket connection by trying each endpoint in a sequence.
Definition: connect.hpp:44
int listen(socket_type s, int backlog, asio::error_code &ec)
Definition: socket_ops.ipp:684
signed_size_type send(socket_type s, const buf *bufs, size_t count, int flags, asio::error_code &ec)
shutdown_type
Different ways a socket may be shutdown.
Definition: socket_base.hpp:34
size_t available(socket_type s, asio::error_code &ec)
Definition: socket_ops.ipp:660
int bind(socket_type s, const socket_addr_type *addr, std::size_t addrlen, asio::error_code &ec)
Definition: socket_ops.ipp:278
Class to represent an error code value.
Definition: error_code.hpp:80
socket_type accept(socket_type s, socket_addr_type *addr, std::size_t *addrlen, asio::error_code &ec)
Definition: socket_ops.ipp:101
ASIO_DECL int close(int d, state_type &state, asio::error_code &ec)
int shutdown(socket_type s, int what, asio::error_code &ec)
Definition: socket_ops.ipp:452
binder1< Handler, Arg1 > bind_handler(Handler handler, const Arg1 &arg1)
ASIO_DECL int open(const char *path, int flags, asio::error_code &ec)
Operation not supported.
Definition: error.hpp:166