Realistic 3D camera system
3D camera system components
basic_seq_packet_socket.hpp
Go to the documentation of this file.
1 //
2 // basic_seq_packet_socket.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_BASIC_SEQ_PACKET_SOCKET_HPP
12 #define ASIO_BASIC_SEQ_PACKET_SOCKET_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 #include <cstddef>
20 #include "asio/basic_socket.hpp"
23 #include "asio/error.hpp"
25 
27 
28 namespace asio {
29 
31 
39 template <typename Protocol,
40  typename SeqPacketSocketService = seq_packet_socket_service<Protocol> >
42  : public basic_socket<Protocol, SeqPacketSocketService>
43 {
44 public:
47  typedef typename SeqPacketSocketService::native_handle_type native_type;
48 
50  typedef typename SeqPacketSocketService::native_handle_type
52 
54  typedef Protocol protocol_type;
55 
57  typedef typename Protocol::endpoint endpoint_type;
58 
60 
70  : basic_socket<Protocol, SeqPacketSocketService>(io_service)
71  {
72  }
73 
75 
89  const protocol_type& protocol)
90  : basic_socket<Protocol, SeqPacketSocketService>(io_service, protocol)
91  {
92  }
93 
96 
111  const endpoint_type& endpoint)
112  : basic_socket<Protocol, SeqPacketSocketService>(io_service, endpoint)
113  {
114  }
115 
117 
132  const protocol_type& protocol, const native_handle_type& native_socket)
133  : basic_socket<Protocol, SeqPacketSocketService>(
134  io_service, protocol, native_socket)
135  {
136  }
137 
138 #if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
139 
153  {
154  }
155 
157 
168  {
171  return *this;
172  }
173 
176 
186  template <typename Protocol1, typename SeqPacketSocketService1>
189  typename enable_if<is_convertible<Protocol1, Protocol>::value>::type* = 0)
192  Protocol1, SeqPacketSocketService1>)(other))
193  {
194  }
195 
198 
208  template <typename Protocol1, typename SeqPacketSocketService1>
210  basic_seq_packet_socket>::type& operator=(
212  {
215  Protocol1, SeqPacketSocketService1>)(other));
216  return *this;
217  }
218 #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
219 
221 
243  template <typename ConstBufferSequence>
244  std::size_t send(const ConstBufferSequence& buffers,
246  {
247  asio::error_code ec;
248  std::size_t s = this->get_service().send(
249  this->get_implementation(), buffers, flags, ec);
250  asio::detail::throw_error(ec, "send");
251  return s;
252  }
253 
255 
272  template <typename ConstBufferSequence>
273  std::size_t send(const ConstBufferSequence& buffers,
275  {
276  return this->get_service().send(
277  this->get_implementation(), buffers, flags, ec);
278  }
279 
281 
313  template <typename ConstBufferSequence, typename WriteHandler>
314  ASIO_INITFN_RESULT_TYPE(WriteHandler,
315  void (asio::error_code, std::size_t))
316  async_send(const ConstBufferSequence& buffers,
318  ASIO_MOVE_ARG(WriteHandler) handler)
319  {
320  // If you get an error on the following line it means that your handler does
321  // not meet the documented type requirements for a WriteHandler.
322  ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
323 
324  return this->get_service().async_send(this->get_implementation(),
325  buffers, flags, ASIO_MOVE_CAST(WriteHandler)(handler));
326  }
327 
329 
357  template <typename MutableBufferSequence>
358  std::size_t receive(const MutableBufferSequence& buffers,
360  {
361  asio::error_code ec;
362  std::size_t s = this->get_service().receive(
363  this->get_implementation(), buffers, 0, out_flags, ec);
364  asio::detail::throw_error(ec, "receive");
365  return s;
366  }
367 
369 
403  template <typename MutableBufferSequence>
404  std::size_t receive(const MutableBufferSequence& buffers,
407  {
408  asio::error_code ec;
409  std::size_t s = this->get_service().receive(
410  this->get_implementation(), buffers, in_flags, out_flags, ec);
411  asio::detail::throw_error(ec, "receive");
412  return s;
413  }
414 
416 
438  template <typename MutableBufferSequence>
439  std::size_t receive(const MutableBufferSequence& buffers,
442  {
443  return this->get_service().receive(this->get_implementation(),
444  buffers, in_flags, out_flags, ec);
445  }
446 
448 
485  template <typename MutableBufferSequence, typename ReadHandler>
486  ASIO_INITFN_RESULT_TYPE(ReadHandler,
487  void (asio::error_code, std::size_t))
488  async_receive(const MutableBufferSequence& buffers,
490  ASIO_MOVE_ARG(ReadHandler) handler)
491  {
492  // If you get an error on the following line it means that your handler does
493  // not meet the documented type requirements for a ReadHandler.
494  ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
495 
496  return this->get_service().async_receive(
497  this->get_implementation(), buffers, 0, out_flags,
498  ASIO_MOVE_CAST(ReadHandler)(handler));
499  }
500 
502 
543  template <typename MutableBufferSequence, typename ReadHandler>
544  ASIO_INITFN_RESULT_TYPE(ReadHandler,
545  void (asio::error_code, std::size_t))
546  async_receive(const MutableBufferSequence& buffers,
548  socket_base::message_flags& out_flags,
549  ASIO_MOVE_ARG(ReadHandler) handler)
550  {
551  // If you get an error on the following line it means that your handler does
552  // not meet the documented type requirements for a ReadHandler.
553  ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
554 
555  return this->get_service().async_receive(
556  this->get_implementation(), buffers, in_flags, out_flags,
557  ASIO_MOVE_CAST(ReadHandler)(handler));
558  }
559 };
560 
561 } // namespace asio
562 
564 
565 #endif // ASIO_BASIC_SEQ_PACKET_SOCKET_HPP
int message_flags
Bitmask type for flags that can be passed to send and receive operations.
Definition: socket_base.hpp:53
basic_seq_packet_socket(asio::io_service &io_service, const protocol_type &protocol, const native_handle_type &native_socket)
Construct a basic_seq_packet_socket on an existing native socket.
SeqPacketSocketService::native_handle_type native_type
void throw_error(const asio::error_code &err)
Definition: throw_error.hpp:31
Protocol protocol_type
The protocol type.
SeqPacketSocketService::native_handle_type native_handle_type
The native representation of a socket.
Provides core I/O functionality.
Definition: io_service.hpp:184
service_type & get_service()
Get the service associated with the I/O object.
#define ASIO_MOVE_CAST2(type1, type2)
Definition: config.hpp:139
SocketService & s
Definition: connect.hpp:521
std::size_t send(const ConstBufferSequence &buffers, socket_base::message_flags flags)
Send some data on the socket.
std::size_t receive(const MutableBufferSequence &buffers, socket_base::message_flags in_flags, socket_base::message_flags &out_flags)
Receive some data on the socket.
socket_base::message_flags & out_flags
basic_seq_packet_socket(asio::io_service &io_service, const endpoint_type &endpoint)
basic_seq_packet_socket(asio::io_service &io_service, const protocol_type &protocol)
Construct and open a basic_seq_packet_socket.
const MutableBufferSequence & buffers
Definition: read.hpp:521
#define ASIO_READ_HANDLER_CHECK(handler_type, handler)
socket_base::message_flags in_flags
implementation_type & get_implementation()
Get the underlying implementation of the I/O object.
socket_base::message_flags ASIO_MOVE_ARG(WriteHandler) handler)
socket_base::message_flags socket_base::message_flags ASIO_MOVE_ARG(ReadHandler) handler)
ASIO_INITFN_RESULT_TYPE(WriteHandler, void(asio::error_code, std::size_t)) async_send(const ConstBufferSequence &buffers
Start an asynchronous send.
Class to represent an error code value.
Definition: error_code.hpp:80
basic_seq_packet_socket(asio::io_service &io_service)
Construct a basic_seq_packet_socket without opening it.
std::size_t receive(const MutableBufferSequence &buffers, socket_base::message_flags in_flags, socket_base::message_flags &out_flags, asio::error_code &ec)
Receive some data on a connected socket.
Provides sequenced packet socket functionality.
std::size_t send(const ConstBufferSequence &buffers, socket_base::message_flags flags, asio::error_code &ec)
Send some data on the socket.
socket_base::message_flags ASIO_MOVE_ARG(ReadHandler) handler)
Provides socket functionality.
#define ASIO_MOVE_CAST(type)
Definition: config.hpp:138
Protocol::endpoint endpoint_type
The endpoint type.
std::size_t receive(const MutableBufferSequence &buffers, socket_base::message_flags &out_flags)
Receive some data on the socket.
#define ASIO_WRITE_HANDLER_CHECK(handler_type, handler)