Chris@16: // Chris@16: // detail/descriptor_ops.hpp Chris@16: // ~~~~~~~~~~~~~~~~~~~~~~~~~ Chris@16: // Chris@101: // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com) Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: Chris@16: #ifndef BOOST_ASIO_DETAIL_DESCRIPTOR_OPS_HPP Chris@16: #define BOOST_ASIO_DETAIL_DESCRIPTOR_OPS_HPP Chris@16: Chris@16: #if defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: # pragma once Chris@16: #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: Chris@16: #include Chris@16: Chris@16: #if !defined(BOOST_ASIO_WINDOWS) \ Chris@16: && !defined(BOOST_ASIO_WINDOWS_RUNTIME) \ Chris@16: && !defined(__CYGWIN__) Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace asio { Chris@16: namespace detail { Chris@16: namespace descriptor_ops { Chris@16: Chris@16: // Descriptor state bits. Chris@16: enum Chris@16: { Chris@16: // The user wants a non-blocking descriptor. Chris@16: user_set_non_blocking = 1, Chris@16: Chris@16: // The descriptor has been set non-blocking. Chris@16: internal_non_blocking = 2, Chris@16: Chris@16: // Helper "state" used to determine whether the descriptor is non-blocking. Chris@16: non_blocking = user_set_non_blocking | internal_non_blocking, Chris@16: Chris@16: // The descriptor may have been dup()-ed. Chris@16: possible_dup = 4 Chris@16: }; Chris@16: Chris@16: typedef unsigned char state_type; Chris@16: Chris@16: template Chris@16: inline ReturnType error_wrapper(ReturnType return_value, Chris@16: boost::system::error_code& ec) Chris@16: { Chris@16: ec = boost::system::error_code(errno, Chris@16: boost::asio::error::get_system_category()); Chris@16: return return_value; Chris@16: } Chris@16: Chris@16: BOOST_ASIO_DECL int open(const char* path, int flags, Chris@16: boost::system::error_code& ec); Chris@16: Chris@16: BOOST_ASIO_DECL int close(int d, state_type& state, Chris@16: boost::system::error_code& ec); Chris@16: Chris@16: BOOST_ASIO_DECL bool set_user_non_blocking(int d, Chris@16: state_type& state, bool value, boost::system::error_code& ec); Chris@16: Chris@16: BOOST_ASIO_DECL bool set_internal_non_blocking(int d, Chris@16: state_type& state, bool value, boost::system::error_code& ec); Chris@16: Chris@16: typedef iovec buf; Chris@16: Chris@16: BOOST_ASIO_DECL std::size_t sync_read(int d, state_type state, buf* bufs, Chris@16: std::size_t count, bool all_empty, boost::system::error_code& ec); Chris@16: Chris@16: BOOST_ASIO_DECL bool non_blocking_read(int d, buf* bufs, std::size_t count, Chris@16: boost::system::error_code& ec, std::size_t& bytes_transferred); Chris@16: Chris@16: BOOST_ASIO_DECL std::size_t sync_write(int d, state_type state, Chris@16: const buf* bufs, std::size_t count, bool all_empty, Chris@16: boost::system::error_code& ec); Chris@16: Chris@16: BOOST_ASIO_DECL bool non_blocking_write(int d, Chris@16: const buf* bufs, std::size_t count, Chris@16: boost::system::error_code& ec, std::size_t& bytes_transferred); Chris@16: Chris@16: BOOST_ASIO_DECL int ioctl(int d, state_type& state, long cmd, Chris@16: ioctl_arg_type* arg, boost::system::error_code& ec); Chris@16: Chris@16: BOOST_ASIO_DECL int fcntl(int d, int cmd, boost::system::error_code& ec); Chris@16: Chris@16: BOOST_ASIO_DECL int fcntl(int d, int cmd, Chris@16: long arg, boost::system::error_code& ec); Chris@16: Chris@16: BOOST_ASIO_DECL int poll_read(int d, Chris@16: state_type state, boost::system::error_code& ec); Chris@16: Chris@16: BOOST_ASIO_DECL int poll_write(int d, Chris@16: state_type state, boost::system::error_code& ec); Chris@16: Chris@16: } // namespace descriptor_ops Chris@16: } // namespace detail Chris@16: } // namespace asio Chris@16: } // namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #if defined(BOOST_ASIO_HEADER_ONLY) Chris@16: # include Chris@16: #endif // defined(BOOST_ASIO_HEADER_ONLY) Chris@16: Chris@16: #endif // !defined(BOOST_ASIO_WINDOWS) Chris@16: // && !defined(BOOST_ASIO_WINDOWS_RUNTIME) Chris@16: // && !defined(__CYGWIN__) Chris@16: Chris@16: #endif // BOOST_ASIO_DETAIL_DESCRIPTOR_OPS_HPP