Chris@16
|
1 //
|
Chris@16
|
2 // posix/descriptor_base.hpp
|
Chris@16
|
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~
|
Chris@16
|
4 //
|
Chris@101
|
5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
Chris@16
|
6 //
|
Chris@16
|
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
9 //
|
Chris@16
|
10
|
Chris@16
|
11 #ifndef BOOST_ASIO_POSIX_DESCRIPTOR_BASE_HPP
|
Chris@16
|
12 #define BOOST_ASIO_POSIX_DESCRIPTOR_BASE_HPP
|
Chris@16
|
13
|
Chris@16
|
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
Chris@16
|
15 # pragma once
|
Chris@16
|
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
Chris@16
|
17
|
Chris@16
|
18 #include <boost/asio/detail/config.hpp>
|
Chris@16
|
19
|
Chris@16
|
20 #if defined(BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR) \
|
Chris@16
|
21 || defined(GENERATING_DOCUMENTATION)
|
Chris@16
|
22
|
Chris@16
|
23 #include <boost/asio/detail/io_control.hpp>
|
Chris@16
|
24 #include <boost/asio/detail/socket_option.hpp>
|
Chris@16
|
25
|
Chris@16
|
26 #include <boost/asio/detail/push_options.hpp>
|
Chris@16
|
27
|
Chris@16
|
28 namespace boost {
|
Chris@16
|
29 namespace asio {
|
Chris@16
|
30 namespace posix {
|
Chris@16
|
31
|
Chris@16
|
32 /// The descriptor_base class is used as a base for the basic_stream_descriptor
|
Chris@16
|
33 /// class template so that we have a common place to define the associated
|
Chris@16
|
34 /// IO control commands.
|
Chris@16
|
35 class descriptor_base
|
Chris@16
|
36 {
|
Chris@16
|
37 public:
|
Chris@16
|
38 /// (Deprecated: Use non_blocking().) IO control command to set the blocking
|
Chris@16
|
39 /// mode of the descriptor.
|
Chris@16
|
40 /**
|
Chris@16
|
41 * Implements the FIONBIO IO control command.
|
Chris@16
|
42 *
|
Chris@16
|
43 * @par Example
|
Chris@16
|
44 * @code
|
Chris@16
|
45 * boost::asio::posix::stream_descriptor descriptor(io_service);
|
Chris@16
|
46 * ...
|
Chris@16
|
47 * boost::asio::descriptor_base::non_blocking_io command(true);
|
Chris@16
|
48 * descriptor.io_control(command);
|
Chris@16
|
49 * @endcode
|
Chris@16
|
50 *
|
Chris@16
|
51 * @par Concepts:
|
Chris@16
|
52 * IoControlCommand.
|
Chris@16
|
53 */
|
Chris@16
|
54 #if defined(GENERATING_DOCUMENTATION)
|
Chris@16
|
55 typedef implementation_defined non_blocking_io;
|
Chris@16
|
56 #else
|
Chris@16
|
57 typedef boost::asio::detail::io_control::non_blocking_io non_blocking_io;
|
Chris@16
|
58 #endif
|
Chris@16
|
59
|
Chris@16
|
60 /// IO control command to get the amount of data that can be read without
|
Chris@16
|
61 /// blocking.
|
Chris@16
|
62 /**
|
Chris@16
|
63 * Implements the FIONREAD IO control command.
|
Chris@16
|
64 *
|
Chris@16
|
65 * @par Example
|
Chris@16
|
66 * @code
|
Chris@16
|
67 * boost::asio::posix::stream_descriptor descriptor(io_service);
|
Chris@16
|
68 * ...
|
Chris@16
|
69 * boost::asio::descriptor_base::bytes_readable command(true);
|
Chris@16
|
70 * descriptor.io_control(command);
|
Chris@16
|
71 * std::size_t bytes_readable = command.get();
|
Chris@16
|
72 * @endcode
|
Chris@16
|
73 *
|
Chris@16
|
74 * @par Concepts:
|
Chris@16
|
75 * IoControlCommand.
|
Chris@16
|
76 */
|
Chris@16
|
77 #if defined(GENERATING_DOCUMENTATION)
|
Chris@16
|
78 typedef implementation_defined bytes_readable;
|
Chris@16
|
79 #else
|
Chris@16
|
80 typedef boost::asio::detail::io_control::bytes_readable bytes_readable;
|
Chris@16
|
81 #endif
|
Chris@16
|
82
|
Chris@16
|
83 protected:
|
Chris@16
|
84 /// Protected destructor to prevent deletion through this type.
|
Chris@16
|
85 ~descriptor_base()
|
Chris@16
|
86 {
|
Chris@16
|
87 }
|
Chris@16
|
88 };
|
Chris@16
|
89
|
Chris@16
|
90 } // namespace posix
|
Chris@16
|
91 } // namespace asio
|
Chris@16
|
92 } // namespace boost
|
Chris@16
|
93
|
Chris@16
|
94 #include <boost/asio/detail/pop_options.hpp>
|
Chris@16
|
95
|
Chris@16
|
96 #endif // defined(BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR)
|
Chris@16
|
97 // || defined(GENERATING_DOCUMENTATION)
|
Chris@16
|
98
|
Chris@16
|
99 #endif // BOOST_ASIO_POSIX_DESCRIPTOR_BASE_HPP
|