2 // detail/descriptor_ops.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2014 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/system/error_code.hpp>
26 #include <boost/asio/detail/socket_types.hpp>
28 #include <boost/asio/detail/push_options.hpp>
33 namespace descriptor_ops {
35 // Descriptor state bits.
38 // The user wants a non-blocking descriptor.
39 user_set_non_blocking = 1,
41 // The descriptor has been set non-blocking.
42 internal_non_blocking = 2,
44 // Helper "state" used to determine whether the descriptor is non-blocking.
45 non_blocking = user_set_non_blocking | internal_non_blocking,
47 // The descriptor may have been dup()-ed.
51 typedef unsigned char state_type;
53 template <typename ReturnType>
54 inline ReturnType error_wrapper(ReturnType return_value,
55 boost::system::error_code& ec)
57 ec = boost::system::error_code(errno,
58 boost::asio::error::get_system_category());
62 BOOST_ASIO_DECL int open(const char* path, int flags,
63 boost::system::error_code& ec);
65 BOOST_ASIO_DECL int close(int d, state_type& state,
66 boost::system::error_code& ec);
68 BOOST_ASIO_DECL bool set_user_non_blocking(int d,
69 state_type& state, bool value, boost::system::error_code& ec);
71 BOOST_ASIO_DECL bool set_internal_non_blocking(int d,
72 state_type& state, bool value, boost::system::error_code& ec);
76 BOOST_ASIO_DECL std::size_t sync_read(int d, state_type state, buf* bufs,
77 std::size_t count, bool all_empty, boost::system::error_code& ec);
79 BOOST_ASIO_DECL bool non_blocking_read(int d, buf* bufs, std::size_t count,
80 boost::system::error_code& ec, std::size_t& bytes_transferred);
82 BOOST_ASIO_DECL std::size_t sync_write(int d, state_type state,
83 const buf* bufs, std::size_t count, bool all_empty,
84 boost::system::error_code& ec);
86 BOOST_ASIO_DECL bool non_blocking_write(int d,
87 const buf* bufs, std::size_t count,
88 boost::system::error_code& ec, std::size_t& bytes_transferred);
90 BOOST_ASIO_DECL int ioctl(int d, state_type& state, long cmd,
91 ioctl_arg_type* arg, boost::system::error_code& ec);
93 BOOST_ASIO_DECL int fcntl(int d, int cmd, boost::system::error_code& ec);
95 BOOST_ASIO_DECL int fcntl(int d, int cmd,
96 long arg, boost::system::error_code& ec);
98 BOOST_ASIO_DECL int poll_read(int d,
99 state_type state, boost::system::error_code& ec);
101 BOOST_ASIO_DECL int poll_write(int d,
102 state_type state, boost::system::error_code& ec);
104 } // namespace descriptor_ops
105 } // namespace detail
109 #include <boost/asio/detail/pop_options.hpp>
111 #if defined(BOOST_ASIO_HEADER_ONLY)
112 # include <boost/asio/detail/impl/descriptor_ops.ipp>
113 #endif // defined(BOOST_ASIO_HEADER_ONLY)
115 #endif // !defined(BOOST_ASIO_WINDOWS)
116 // && !defined(BOOST_ASIO_WINDOWS_RUNTIME)
117 // && !defined(__CYGWIN__)
119 #endif // BOOST_ASIO_DETAIL_DESCRIPTOR_OPS_HPP