2 // detail/descriptor_ops.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2020 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_DESCRIPTOR_OPS_HPP
12 #define BOOST_ASIO_DETAIL_DESCRIPTOR_OPS_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 #if !defined(BOOST_ASIO_WINDOWS) \
21 && !defined(BOOST_ASIO_WINDOWS_RUNTIME) \
22 && !defined(__CYGWIN__)
25 #include <boost/asio/error.hpp>
26 #include <boost/system/error_code.hpp>
27 #include <boost/asio/detail/socket_types.hpp>
29 #include <boost/asio/detail/push_options.hpp>
34 namespace descriptor_ops {
36 // Descriptor state bits.
39 // The user wants a non-blocking descriptor.
40 user_set_non_blocking = 1,
42 // The descriptor has been set non-blocking.
43 internal_non_blocking = 2,
45 // Helper "state" used to determine whether the descriptor is non-blocking.
46 non_blocking = user_set_non_blocking | internal_non_blocking,
48 // The descriptor may have been dup()-ed.
52 typedef unsigned char state_type;
54 inline void get_last_error(
55 boost::system::error_code& ec, bool is_error_condition)
57 if (!is_error_condition)
59 ec.assign(0, ec.category());
63 ec = boost::system::error_code(errno,
64 boost::asio::error::get_system_category());
68 BOOST_ASIO_DECL int open(const char* path, int flags,
69 boost::system::error_code& ec);
71 BOOST_ASIO_DECL int close(int d, state_type& state,
72 boost::system::error_code& ec);
74 BOOST_ASIO_DECL bool set_user_non_blocking(int d,
75 state_type& state, bool value, boost::system::error_code& ec);
77 BOOST_ASIO_DECL bool set_internal_non_blocking(int d,
78 state_type& state, bool value, boost::system::error_code& ec);
82 BOOST_ASIO_DECL std::size_t sync_read(int d, state_type state, buf* bufs,
83 std::size_t count, bool all_empty, boost::system::error_code& ec);
85 BOOST_ASIO_DECL std::size_t sync_read1(int d, state_type state, void* data,
86 std::size_t size, boost::system::error_code& ec);
88 BOOST_ASIO_DECL bool non_blocking_read(int d, buf* bufs, std::size_t count,
89 boost::system::error_code& ec, std::size_t& bytes_transferred);
91 BOOST_ASIO_DECL bool non_blocking_read1(int d, void* data, std::size_t size,
92 boost::system::error_code& ec, std::size_t& bytes_transferred);
94 BOOST_ASIO_DECL std::size_t sync_write(int d, state_type state,
95 const buf* bufs, std::size_t count, bool all_empty,
96 boost::system::error_code& ec);
98 BOOST_ASIO_DECL std::size_t sync_write1(int d, state_type state,
99 const void* data, std::size_t size, boost::system::error_code& ec);
101 BOOST_ASIO_DECL bool non_blocking_write(int d,
102 const buf* bufs, std::size_t count,
103 boost::system::error_code& ec, std::size_t& bytes_transferred);
105 BOOST_ASIO_DECL bool non_blocking_write1(int d,
106 const void* data, std::size_t size,
107 boost::system::error_code& ec, std::size_t& bytes_transferred);
109 BOOST_ASIO_DECL int ioctl(int d, state_type& state, long cmd,
110 ioctl_arg_type* arg, boost::system::error_code& ec);
112 BOOST_ASIO_DECL int fcntl(int d, int cmd, boost::system::error_code& ec);
114 BOOST_ASIO_DECL int fcntl(int d, int cmd,
115 long arg, boost::system::error_code& ec);
117 BOOST_ASIO_DECL int poll_read(int d,
118 state_type state, boost::system::error_code& ec);
120 BOOST_ASIO_DECL int poll_write(int d,
121 state_type state, boost::system::error_code& ec);
123 BOOST_ASIO_DECL int poll_error(int d,
124 state_type state, boost::system::error_code& ec);
126 } // namespace descriptor_ops
127 } // namespace detail
131 #include <boost/asio/detail/pop_options.hpp>
133 #if defined(BOOST_ASIO_HEADER_ONLY)
134 # include <boost/asio/detail/impl/descriptor_ops.ipp>
135 #endif // defined(BOOST_ASIO_HEADER_ONLY)
137 #endif // !defined(BOOST_ASIO_WINDOWS)
138 // && !defined(BOOST_ASIO_WINDOWS_RUNTIME)
139 // && !defined(__CYGWIN__)
141 #endif // BOOST_ASIO_DETAIL_DESCRIPTOR_OPS_HPP