2 // detail/io_control.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
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)
11 #ifndef BOOST_ASIO_DETAIL_IO_CONTROL_HPP
12 #define BOOST_ASIO_DETAIL_IO_CONTROL_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/config.hpp>
20 #include <boost/asio/detail/socket_types.hpp>
22 #include <boost/asio/detail/push_options.hpp>
27 namespace io_control {
29 // IO control command for non-blocking I/O.
33 // Default constructor.
39 // Construct with a specific command value.
40 non_blocking_io(bool value)
41 : value_(value ? 1 : 0)
45 // Get the name of the IO control command.
48 return static_cast<int>(BOOST_ASIO_OS_DEF(FIONBIO));
51 // Set the value of the I/O control command.
54 value_ = value ? 1 : 0;
57 // Get the current value of the I/O control command.
63 // Get the address of the command data.
64 detail::ioctl_arg_type* data()
69 // Get the address of the command data.
70 const detail::ioctl_arg_type* data() const
76 detail::ioctl_arg_type value_;
79 // I/O control command for getting number of bytes available.
83 // Default constructor.
89 // Construct with a specific command value.
90 bytes_readable(std::size_t value)
91 : value_(static_cast<detail::ioctl_arg_type>(value))
95 // Get the name of the IO control command.
98 return static_cast<int>(BOOST_ASIO_OS_DEF(FIONREAD));
101 // Set the value of the I/O control command.
102 void set(std::size_t value)
104 value_ = static_cast<detail::ioctl_arg_type>(value);
107 // Get the current value of the I/O control command.
108 std::size_t get() const
110 return static_cast<std::size_t>(value_);
113 // Get the address of the command data.
114 detail::ioctl_arg_type* data()
119 // Get the address of the command data.
120 const detail::ioctl_arg_type* data() const
126 detail::ioctl_arg_type value_;
129 } // namespace io_control
130 } // namespace detail
134 #include <boost/asio/detail/pop_options.hpp>
136 #endif // BOOST_ASIO_DETAIL_IO_CONTROL_HPP