]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/asio/detail/null_socket_service.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / asio / detail / null_socket_service.hpp
1 //
2 // detail/null_socket_service.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2017 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 BOOST_ASIO_DETAIL_NULL_SOCKET_SERVICE_HPP
12 #define BOOST_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 <boost/asio/detail/config.hpp>
19
20 #if defined(BOOST_ASIO_WINDOWS_RUNTIME)
21
22 #include <boost/asio/buffer.hpp>
23 #include <boost/asio/error.hpp>
24 #include <boost/asio/io_context.hpp>
25 #include <boost/asio/socket_base.hpp>
26 #include <boost/asio/detail/bind_handler.hpp>
27
28 #include <boost/asio/detail/push_options.hpp>
29
30 namespace boost {
31 namespace asio {
32 namespace detail {
33
34 template <typename Protocol>
35 class null_socket_service :
36 public service_base<null_socket_service<Protocol> >
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 int native_handle_type;
47
48 // The implementation type of the socket.
49 struct implementation_type
50 {
51 };
52
53 // Constructor.
54 null_socket_service(boost::asio::io_context& io_context)
55 : service_base<null_socket_service<Protocol> >(io_context),
56 io_context_(io_context)
57 {
58 }
59
60 // Destroy all user-defined handler objects owned by the service.
61 void shutdown()
62 {
63 }
64
65 // Construct a new socket implementation.
66 void construct(implementation_type&)
67 {
68 }
69
70 // Move-construct a new socket implementation.
71 void move_construct(implementation_type&, implementation_type&)
72 {
73 }
74
75 // Move-assign from another socket implementation.
76 void move_assign(implementation_type&,
77 null_socket_service&, implementation_type&)
78 {
79 }
80
81 // Move-construct a new socket implementation from another protocol type.
82 template <typename Protocol1>
83 void converting_move_construct(implementation_type&,
84 null_socket_service<Protocol1>&,
85 typename null_socket_service<Protocol1>::implementation_type&)
86 {
87 }
88
89 // Destroy a socket implementation.
90 void destroy(implementation_type&)
91 {
92 }
93
94 // Open a new socket implementation.
95 boost::system::error_code open(implementation_type&,
96 const protocol_type&, boost::system::error_code& ec)
97 {
98 ec = boost::asio::error::operation_not_supported;
99 return ec;
100 }
101
102 // Assign a native socket to a socket implementation.
103 boost::system::error_code assign(implementation_type&, const protocol_type&,
104 const native_handle_type&, boost::system::error_code& ec)
105 {
106 ec = boost::asio::error::operation_not_supported;
107 return ec;
108 }
109
110 // Determine whether the socket is open.
111 bool is_open(const implementation_type&) const
112 {
113 return false;
114 }
115
116 // Destroy a socket implementation.
117 boost::system::error_code close(implementation_type&,
118 boost::system::error_code& ec)
119 {
120 ec = boost::asio::error::operation_not_supported;
121 return ec;
122 }
123
124 // Release ownership of the socket.
125 native_handle_type release(implementation_type&,
126 boost::system::error_code& ec)
127 {
128 ec = boost::asio::error::operation_not_supported;
129 return 0;
130 }
131
132 // Get the native socket representation.
133 native_handle_type native_handle(implementation_type&)
134 {
135 return 0;
136 }
137
138 // Cancel all operations associated with the socket.
139 boost::system::error_code cancel(implementation_type&,
140 boost::system::error_code& ec)
141 {
142 ec = boost::asio::error::operation_not_supported;
143 return ec;
144 }
145
146 // Determine whether the socket is at the out-of-band data mark.
147 bool at_mark(const implementation_type&,
148 boost::system::error_code& ec) const
149 {
150 ec = boost::asio::error::operation_not_supported;
151 return false;
152 }
153
154 // Determine the number of bytes available for reading.
155 std::size_t available(const implementation_type&,
156 boost::system::error_code& ec) const
157 {
158 ec = boost::asio::error::operation_not_supported;
159 return 0;
160 }
161
162 // Place the socket into the state where it will listen for new connections.
163 boost::system::error_code listen(implementation_type&,
164 int, boost::system::error_code& ec)
165 {
166 ec = boost::asio::error::operation_not_supported;
167 return ec;
168 }
169
170 // Perform an IO control command on the socket.
171 template <typename IO_Control_Command>
172 boost::system::error_code io_control(implementation_type&,
173 IO_Control_Command&, boost::system::error_code& ec)
174 {
175 ec = boost::asio::error::operation_not_supported;
176 return ec;
177 }
178
179 // Gets the non-blocking mode of the socket.
180 bool non_blocking(const implementation_type&) const
181 {
182 return false;
183 }
184
185 // Sets the non-blocking mode of the socket.
186 boost::system::error_code non_blocking(implementation_type&,
187 bool, boost::system::error_code& ec)
188 {
189 ec = boost::asio::error::operation_not_supported;
190 return ec;
191 }
192
193 // Gets the non-blocking mode of the native socket implementation.
194 bool native_non_blocking(const implementation_type&) const
195 {
196 return false;
197 }
198
199 // Sets the non-blocking mode of the native socket implementation.
200 boost::system::error_code native_non_blocking(implementation_type&,
201 bool, boost::system::error_code& ec)
202 {
203 ec = boost::asio::error::operation_not_supported;
204 return ec;
205 }
206
207 // Disable sends or receives on the socket.
208 boost::system::error_code shutdown(implementation_type&,
209 socket_base::shutdown_type, boost::system::error_code& ec)
210 {
211 ec = boost::asio::error::operation_not_supported;
212 return ec;
213 }
214
215 // Bind the socket to the specified local endpoint.
216 boost::system::error_code bind(implementation_type&,
217 const endpoint_type&, boost::system::error_code& ec)
218 {
219 ec = boost::asio::error::operation_not_supported;
220 return ec;
221 }
222
223 // Set a socket option.
224 template <typename Option>
225 boost::system::error_code set_option(implementation_type&,
226 const Option&, boost::system::error_code& ec)
227 {
228 ec = boost::asio::error::operation_not_supported;
229 return ec;
230 }
231
232 // Set a socket option.
233 template <typename Option>
234 boost::system::error_code get_option(const implementation_type&,
235 Option&, boost::system::error_code& ec) const
236 {
237 ec = boost::asio::error::operation_not_supported;
238 return ec;
239 }
240
241 // Get the local endpoint.
242 endpoint_type local_endpoint(const implementation_type&,
243 boost::system::error_code& ec) const
244 {
245 ec = boost::asio::error::operation_not_supported;
246 return endpoint_type();
247 }
248
249 // Get the remote endpoint.
250 endpoint_type remote_endpoint(const implementation_type&,
251 boost::system::error_code& ec) const
252 {
253 ec = boost::asio::error::operation_not_supported;
254 return endpoint_type();
255 }
256
257 // Send the given data to the peer.
258 template <typename ConstBufferSequence>
259 std::size_t send(implementation_type&, const ConstBufferSequence&,
260 socket_base::message_flags, boost::system::error_code& ec)
261 {
262 ec = boost::asio::error::operation_not_supported;
263 return 0;
264 }
265
266 // Wait until data can be sent without blocking.
267 std::size_t send(implementation_type&, const null_buffers&,
268 socket_base::message_flags, boost::system::error_code& ec)
269 {
270 ec = boost::asio::error::operation_not_supported;
271 return 0;
272 }
273
274 // Start an asynchronous send. The data being sent must be valid for the
275 // lifetime of the asynchronous operation.
276 template <typename ConstBufferSequence, typename Handler>
277 void async_send(implementation_type&, const ConstBufferSequence&,
278 socket_base::message_flags, Handler& handler)
279 {
280 boost::system::error_code ec = boost::asio::error::operation_not_supported;
281 const std::size_t bytes_transferred = 0;
282 io_context_.post(detail::bind_handler(handler, ec, bytes_transferred));
283 }
284
285 // Start an asynchronous wait until data can be sent without blocking.
286 template <typename Handler>
287 void async_send(implementation_type&, const null_buffers&,
288 socket_base::message_flags, Handler& handler)
289 {
290 boost::system::error_code ec = boost::asio::error::operation_not_supported;
291 const std::size_t bytes_transferred = 0;
292 io_context_.post(detail::bind_handler(handler, ec, bytes_transferred));
293 }
294
295 // Receive some data from the peer. Returns the number of bytes received.
296 template <typename MutableBufferSequence>
297 std::size_t receive(implementation_type&, const MutableBufferSequence&,
298 socket_base::message_flags, boost::system::error_code& ec)
299 {
300 ec = boost::asio::error::operation_not_supported;
301 return 0;
302 }
303
304 // Wait until data can be received without blocking.
305 std::size_t receive(implementation_type&, const null_buffers&,
306 socket_base::message_flags, boost::system::error_code& ec)
307 {
308 ec = boost::asio::error::operation_not_supported;
309 return 0;
310 }
311
312 // Start an asynchronous receive. The buffer for the data being received
313 // must be valid for the lifetime of the asynchronous operation.
314 template <typename MutableBufferSequence, typename Handler>
315 void async_receive(implementation_type&, const MutableBufferSequence&,
316 socket_base::message_flags, Handler& handler)
317 {
318 boost::system::error_code ec = boost::asio::error::operation_not_supported;
319 const std::size_t bytes_transferred = 0;
320 io_context_.post(detail::bind_handler(handler, ec, bytes_transferred));
321 }
322
323 // Wait until data can be received without blocking.
324 template <typename Handler>
325 void async_receive(implementation_type&, const null_buffers&,
326 socket_base::message_flags, Handler& handler)
327 {
328 boost::system::error_code ec = boost::asio::error::operation_not_supported;
329 const std::size_t bytes_transferred = 0;
330 io_context_.post(detail::bind_handler(handler, ec, bytes_transferred));
331 }
332
333 // Receive some data with associated flags. Returns the number of bytes
334 // received.
335 template <typename MutableBufferSequence>
336 std::size_t receive_with_flags(implementation_type&,
337 const MutableBufferSequence&, socket_base::message_flags,
338 socket_base::message_flags&, boost::system::error_code& ec)
339 {
340 ec = boost::asio::error::operation_not_supported;
341 return 0;
342 }
343
344 // Wait until data can be received without blocking.
345 std::size_t receive_with_flags(implementation_type&,
346 const null_buffers&, socket_base::message_flags,
347 socket_base::message_flags&, boost::system::error_code& ec)
348 {
349 ec = boost::asio::error::operation_not_supported;
350 return 0;
351 }
352
353 // Start an asynchronous receive. The buffer for the data being received
354 // must be valid for the lifetime of the asynchronous operation.
355 template <typename MutableBufferSequence, typename Handler>
356 void async_receive_with_flags(implementation_type&,
357 const MutableBufferSequence&, socket_base::message_flags,
358 socket_base::message_flags&, Handler& handler)
359 {
360 boost::system::error_code ec = boost::asio::error::operation_not_supported;
361 const std::size_t bytes_transferred = 0;
362 io_context_.post(detail::bind_handler(handler, ec, bytes_transferred));
363 }
364
365 // Wait until data can be received without blocking.
366 template <typename Handler>
367 void async_receive_with_flags(implementation_type&,
368 const null_buffers&, socket_base::message_flags,
369 socket_base::message_flags&, Handler& handler)
370 {
371 boost::system::error_code ec = boost::asio::error::operation_not_supported;
372 const std::size_t bytes_transferred = 0;
373 io_context_.post(detail::bind_handler(handler, ec, bytes_transferred));
374 }
375
376 // Send a datagram to the specified endpoint. Returns the number of bytes
377 // sent.
378 template <typename ConstBufferSequence>
379 std::size_t send_to(implementation_type&, const ConstBufferSequence&,
380 const endpoint_type&, socket_base::message_flags,
381 boost::system::error_code& ec)
382 {
383 ec = boost::asio::error::operation_not_supported;
384 return 0;
385 }
386
387 // Wait until data can be sent without blocking.
388 std::size_t send_to(implementation_type&, const null_buffers&,
389 const endpoint_type&, socket_base::message_flags,
390 boost::system::error_code& ec)
391 {
392 ec = boost::asio::error::operation_not_supported;
393 return 0;
394 }
395
396 // Start an asynchronous send. The data being sent must be valid for the
397 // lifetime of the asynchronous operation.
398 template <typename ConstBufferSequence, typename Handler>
399 void async_send_to(implementation_type&, const ConstBufferSequence&,
400 const endpoint_type&, socket_base::message_flags,
401 Handler& handler)
402 {
403 boost::system::error_code ec = boost::asio::error::operation_not_supported;
404 const std::size_t bytes_transferred = 0;
405 io_context_.post(detail::bind_handler(handler, ec, bytes_transferred));
406 }
407
408 // Start an asynchronous wait until data can be sent without blocking.
409 template <typename Handler>
410 void async_send_to(implementation_type&, const null_buffers&,
411 const endpoint_type&, socket_base::message_flags, Handler& handler)
412 {
413 boost::system::error_code ec = boost::asio::error::operation_not_supported;
414 const std::size_t bytes_transferred = 0;
415 io_context_.post(detail::bind_handler(handler, ec, bytes_transferred));
416 }
417
418 // Receive a datagram with the endpoint of the sender. Returns the number of
419 // bytes received.
420 template <typename MutableBufferSequence>
421 std::size_t receive_from(implementation_type&, const MutableBufferSequence&,
422 endpoint_type&, socket_base::message_flags,
423 boost::system::error_code& ec)
424 {
425 ec = boost::asio::error::operation_not_supported;
426 return 0;
427 }
428
429 // Wait until data can be received without blocking.
430 std::size_t receive_from(implementation_type&, const null_buffers&,
431 endpoint_type&, socket_base::message_flags,
432 boost::system::error_code& ec)
433 {
434 ec = boost::asio::error::operation_not_supported;
435 return 0;
436 }
437
438 // Start an asynchronous receive. The buffer for the data being received and
439 // the sender_endpoint object must both be valid for the lifetime of the
440 // asynchronous operation.
441 template <typename MutableBufferSequence, typename Handler>
442 void async_receive_from(implementation_type&,
443 const MutableBufferSequence&, endpoint_type&,
444 socket_base::message_flags, Handler& handler)
445 {
446 boost::system::error_code ec = boost::asio::error::operation_not_supported;
447 const std::size_t bytes_transferred = 0;
448 io_context_.post(detail::bind_handler(handler, ec, bytes_transferred));
449 }
450
451 // Wait until data can be received without blocking.
452 template <typename Handler>
453 void async_receive_from(implementation_type&,
454 const null_buffers&, endpoint_type&,
455 socket_base::message_flags, Handler& handler)
456 {
457 boost::system::error_code ec = boost::asio::error::operation_not_supported;
458 const std::size_t bytes_transferred = 0;
459 io_context_.post(detail::bind_handler(handler, ec, bytes_transferred));
460 }
461
462 // Accept a new connection.
463 template <typename Socket>
464 boost::system::error_code accept(implementation_type&,
465 Socket&, endpoint_type*, boost::system::error_code& ec)
466 {
467 ec = boost::asio::error::operation_not_supported;
468 return ec;
469 }
470
471 // Start an asynchronous accept. The peer and peer_endpoint objects
472 // must be valid until the accept's handler is invoked.
473 template <typename Socket, typename Handler>
474 void async_accept(implementation_type&, Socket&,
475 endpoint_type*, Handler& handler)
476 {
477 boost::system::error_code ec = boost::asio::error::operation_not_supported;
478 io_context_.post(detail::bind_handler(handler, ec));
479 }
480
481 // Connect the socket to the specified endpoint.
482 boost::system::error_code connect(implementation_type&,
483 const endpoint_type&, boost::system::error_code& ec)
484 {
485 ec = boost::asio::error::operation_not_supported;
486 return ec;
487 }
488
489 // Start an asynchronous connect.
490 template <typename Handler>
491 void async_connect(implementation_type&,
492 const endpoint_type&, Handler& handler)
493 {
494 boost::system::error_code ec = boost::asio::error::operation_not_supported;
495 io_context_.post(detail::bind_handler(handler, ec));
496 }
497
498 private:
499 boost::asio::io_context& io_context_;
500 };
501
502 } // namespace detail
503 } // namespace asio
504 } // namespace boost
505
506 #include <boost/asio/detail/pop_options.hpp>
507
508 #endif // defined(BOOST_ASIO_WINDOWS_RUNTIME)
509
510 #endif // BOOST_ASIO_DETAIL_NULL_SOCKET_SERVICE_HPP