1//
2// posix/descriptor_base.hpp
3// ~~~~~~~~~~~~~~~~~~~~~~~~~
4//
5// Copyright (c) 2003-2024 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_POSIX_DESCRIPTOR_BASE_HPP
12#define BOOST_ASIO_POSIX_DESCRIPTOR_BASE_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_HAS_POSIX_STREAM_DESCRIPTOR) \
21 || defined(GENERATING_DOCUMENTATION)
22
23#include <boost/asio/detail/io_control.hpp>
24#include <boost/asio/detail/socket_option.hpp>
25
26#include <boost/asio/detail/push_options.hpp>
27
28namespace boost {
29namespace asio {
30namespace posix {
31
32/// The descriptor_base class is used as a base for the descriptor class as a
33/// place to define the associated IO control commands.
34class descriptor_base
35{
36public:
37 /// Wait types.
38 /**
39 * For use with descriptor::wait() and descriptor::async_wait().
40 */
41 enum wait_type
42 {
43 /// Wait for a descriptor to become ready to read.
44 wait_read,
45
46 /// Wait for a descriptor to become ready to write.
47 wait_write,
48
49 /// Wait for a descriptor to have error conditions pending.
50 wait_error
51 };
52
53 /// IO control command to get the amount of data that can be read without
54 /// blocking.
55 /**
56 * Implements the FIONREAD IO control command.
57 *
58 * @par Example
59 * @code
60 * boost::asio::posix::stream_descriptor descriptor(my_context);
61 * ...
62 * boost::asio::descriptor_base::bytes_readable command(true);
63 * descriptor.io_control(command);
64 * std::size_t bytes_readable = command.get();
65 * @endcode
66 *
67 * @par Concepts:
68 * IoControlCommand.
69 */
70#if defined(GENERATING_DOCUMENTATION)
71 typedef implementation_defined bytes_readable;
72#else
73 typedef boost::asio::detail::io_control::bytes_readable bytes_readable;
74#endif
75
76protected:
77 /// Protected destructor to prevent deletion through this type.
78 ~descriptor_base()
79 {
80 }
81};
82
83} // namespace posix
84} // namespace asio
85} // namespace boost
86
87#include <boost/asio/detail/pop_options.hpp>
88
89#endif // defined(BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR)
90 // || defined(GENERATING_DOCUMENTATION)
91
92#endif // BOOST_ASIO_POSIX_DESCRIPTOR_BASE_HPP
93

source code of boost/libs/asio/include/boost/asio/posix/descriptor_base.hpp