Realistic 3D camera system
3D camera system components
winrt_ssocket_service.hpp
Go to the documentation of this file.
1 //
2 // detail/winrt_ssocket_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_WINRT_SSOCKET_SERVICE_HPP
12 #define ASIO_DETAIL_WINRT_SSOCKET_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/error.hpp"
23 #include "asio/io_service.hpp"
28 
30 
31 namespace asio {
32 namespace detail {
33 
34 template <typename Protocol>
35 class winrt_ssocket_service :
36  public winrt_ssocket_service_base
37 {
38 public:
39  // The protocol type.
40  typedef Protocol protocol_type;
41 
42  // The endpoint type.
43  typedef typename Protocol::endpoint endpoint_type;
44 
45  // The native type of a socket.
46  typedef Windows::Networking::Sockets::StreamSocket^ native_handle_type;
47 
48  // The implementation type of the socket.
49  struct implementation_type : base_implementation_type
50  {
51  // Default constructor.
52  implementation_type()
53  : base_implementation_type(),
54  protocol_(endpoint_type().protocol())
55  {
56  }
57 
58  // The protocol associated with the socket.
59  protocol_type protocol_;
60  };
61 
62  // Constructor.
63  winrt_ssocket_service(asio::io_service& io_service)
64  : winrt_ssocket_service_base(io_service)
65  {
66  }
67 
68  // Move-construct a new socket implementation.
69  void move_construct(implementation_type& impl,
70  implementation_type& other_impl)
71  {
72  this->base_move_construct(impl, other_impl);
73 
74  impl.protocol_ = other_impl.protocol_;
75  other_impl.protocol_ = endpoint_type().protocol();
76  }
77 
78  // Move-assign from another socket implementation.
79  void move_assign(implementation_type& impl,
80  winrt_ssocket_service& other_service,
81  implementation_type& other_impl)
82  {
83  this->base_move_assign(impl, other_service, other_impl);
84 
85  impl.protocol_ = other_impl.protocol_;
86  other_impl.protocol_ = endpoint_type().protocol();
87  }
88 
89  // Move-construct a new socket implementation from another protocol type.
90  template <typename Protocol1>
91  void converting_move_construct(implementation_type& impl,
92  typename winrt_ssocket_service<
93  Protocol1>::implementation_type& other_impl)
94  {
95  this->base_move_construct(impl, other_impl);
96 
97  impl.protocol_ = protocol_type(other_impl.protocol_);
98  other_impl.protocol_ = typename Protocol1::endpoint().protocol();
99  }
100 
101  // Open a new socket implementation.
102  asio::error_code open(implementation_type& impl,
103  const protocol_type& protocol, asio::error_code& ec)
104  {
105  if (is_open(impl))
106  {
108  return ec;
109  }
110 
111  try
112  {
113  impl.socket_ = ref new Windows::Networking::Sockets::StreamSocket;
114  impl.protocol_ = protocol;
115  ec = asio::error_code();
116  }
117  catch (Platform::Exception^ e)
118  {
119  ec = asio::error_code(e->HResult,
121  }
122 
123  return ec;
124  }
125 
126  // Assign a native socket to a socket implementation.
127  asio::error_code assign(implementation_type& impl,
128  const protocol_type& protocol, const native_handle_type& native_socket,
129  asio::error_code& ec)
130  {
131  if (is_open(impl))
132  {
134  return ec;
135  }
136 
137  impl.socket_ = native_socket;
138  impl.protocol_ = protocol;
139  ec = asio::error_code();
140 
141  return ec;
142  }
143 
144  // Bind the socket to the specified local endpoint.
145  asio::error_code bind(implementation_type&,
146  const endpoint_type&, asio::error_code& ec)
147  {
149  return ec;
150  }
151 
152  // Get the local endpoint.
153  endpoint_type local_endpoint(const implementation_type& impl,
154  asio::error_code& ec) const
155  {
156  endpoint_type endpoint;
157  endpoint.resize(do_get_endpoint(impl, true,
158  endpoint.data(), endpoint.size(), ec));
159  return endpoint;
160  }
161 
162  // Get the remote endpoint.
163  endpoint_type remote_endpoint(const implementation_type& impl,
164  asio::error_code& ec) const
165  {
166  endpoint_type endpoint;
167  endpoint.resize(do_get_endpoint(impl, false,
168  endpoint.data(), endpoint.size(), ec));
169  return endpoint;
170  }
171 
172  // Set a socket option.
173  template <typename Option>
174  asio::error_code set_option(implementation_type& impl,
175  const Option& option, asio::error_code& ec)
176  {
177  return do_set_option(impl, option.level(impl.protocol_),
178  option.name(impl.protocol_), option.data(impl.protocol_),
179  option.size(impl.protocol_), ec);
180  }
181 
182  // Get a socket option.
183  template <typename Option>
184  asio::error_code get_option(const implementation_type& impl,
185  Option& option, asio::error_code& ec) const
186  {
187  std::size_t size = option.size(impl.protocol_);
188  do_get_option(impl, option.level(impl.protocol_),
189  option.name(impl.protocol_),
190  option.data(impl.protocol_), &size, ec);
191  if (!ec)
192  option.resize(impl.protocol_, size);
193  return ec;
194  }
195 
196  // Connect the socket to the specified endpoint.
197  asio::error_code connect(implementation_type& impl,
198  const endpoint_type& peer_endpoint, asio::error_code& ec)
199  {
200  return do_connect(impl, peer_endpoint.data(), ec);
201  }
202 
203  // Start an asynchronous connect.
204  template <typename Handler>
205  void async_connect(implementation_type& impl,
206  const endpoint_type& peer_endpoint, Handler& handler)
207  {
208  bool is_continuation =
210 
211  // Allocate and construct an operation to wrap the handler.
212  typedef winrt_socket_connect_op<Handler> op;
213  typename op::ptr p = { asio::detail::addressof(handler),
215  sizeof(op), handler), 0 };
216  p.p = new (p.v) op(handler);
217 
218  ASIO_HANDLER_CREATION((p.p, "socket", &impl, "async_connect"));
219 
220  start_connect_op(impl, peer_endpoint.data(), p.p, is_continuation);
221  p.v = p.p = 0;
222  }
223 };
224 
225 } // namespace detail
226 } // namespace asio
227 
229 
230 #endif // defined(ASIO_WINDOWS_RUNTIME)
231 
232 #endif // ASIO_DETAIL_WINRT_SSOCKET_SERVICE_HPP
Provides core I/O functionality.
Definition: io_service.hpp:184
pylon Camera Software Suite for Linux for Use with Basler Gigabit the pylon Viewer and the IP Configurator applications might not be available System I340 and I350 series Although the pylon software will work with any GigE network we would recommend to use one of these adapters USB For U3V devices a USB3 capable USB controller is necessary For best performance and stability we highly recommend a kernel the following settings should be i e
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 bind(socket_type s, const socket_addr_type *addr, std::size_t addrlen, asio::error_code &ec)
Definition: socket_ops.ipp:278
bool is_continuation(Context &context)
Class to represent an error code value.
Definition: error_code.hpp:80
void * allocate(std::size_t s, Handler &h)
Already open.
Definition: error.hpp:214
ASIO_DECL int open(const char *path, int flags, asio::error_code &ec)
#define ASIO_HANDLER_CREATION(args)
ASIO_DECL const error_category & system_category()
Returns the error category used for the system errors produced by asio.
Definition: error_code.ipp:118
Operation not supported.
Definition: error.hpp:166