Chris@16
|
1 //
|
Chris@16
|
2 // detail/descriptor_ops.hpp
|
Chris@16
|
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~
|
Chris@16
|
4 //
|
Chris@101
|
5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
Chris@16
|
6 //
|
Chris@16
|
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
9 //
|
Chris@16
|
10
|
Chris@16
|
11 #ifndef BOOST_ASIO_DETAIL_DESCRIPTOR_OPS_HPP
|
Chris@16
|
12 #define BOOST_ASIO_DETAIL_DESCRIPTOR_OPS_HPP
|
Chris@16
|
13
|
Chris@16
|
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
Chris@16
|
15 # pragma once
|
Chris@16
|
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
Chris@16
|
17
|
Chris@16
|
18 #include <boost/asio/detail/config.hpp>
|
Chris@16
|
19
|
Chris@16
|
20 #if !defined(BOOST_ASIO_WINDOWS) \
|
Chris@16
|
21 && !defined(BOOST_ASIO_WINDOWS_RUNTIME) \
|
Chris@16
|
22 && !defined(__CYGWIN__)
|
Chris@16
|
23
|
Chris@16
|
24 #include <cstddef>
|
Chris@16
|
25 #include <boost/system/error_code.hpp>
|
Chris@16
|
26 #include <boost/asio/detail/socket_types.hpp>
|
Chris@16
|
27
|
Chris@16
|
28 #include <boost/asio/detail/push_options.hpp>
|
Chris@16
|
29
|
Chris@16
|
30 namespace boost {
|
Chris@16
|
31 namespace asio {
|
Chris@16
|
32 namespace detail {
|
Chris@16
|
33 namespace descriptor_ops {
|
Chris@16
|
34
|
Chris@16
|
35 // Descriptor state bits.
|
Chris@16
|
36 enum
|
Chris@16
|
37 {
|
Chris@16
|
38 // The user wants a non-blocking descriptor.
|
Chris@16
|
39 user_set_non_blocking = 1,
|
Chris@16
|
40
|
Chris@16
|
41 // The descriptor has been set non-blocking.
|
Chris@16
|
42 internal_non_blocking = 2,
|
Chris@16
|
43
|
Chris@16
|
44 // Helper "state" used to determine whether the descriptor is non-blocking.
|
Chris@16
|
45 non_blocking = user_set_non_blocking | internal_non_blocking,
|
Chris@16
|
46
|
Chris@16
|
47 // The descriptor may have been dup()-ed.
|
Chris@16
|
48 possible_dup = 4
|
Chris@16
|
49 };
|
Chris@16
|
50
|
Chris@16
|
51 typedef unsigned char state_type;
|
Chris@16
|
52
|
Chris@16
|
53 template <typename ReturnType>
|
Chris@16
|
54 inline ReturnType error_wrapper(ReturnType return_value,
|
Chris@16
|
55 boost::system::error_code& ec)
|
Chris@16
|
56 {
|
Chris@16
|
57 ec = boost::system::error_code(errno,
|
Chris@16
|
58 boost::asio::error::get_system_category());
|
Chris@16
|
59 return return_value;
|
Chris@16
|
60 }
|
Chris@16
|
61
|
Chris@16
|
62 BOOST_ASIO_DECL int open(const char* path, int flags,
|
Chris@16
|
63 boost::system::error_code& ec);
|
Chris@16
|
64
|
Chris@16
|
65 BOOST_ASIO_DECL int close(int d, state_type& state,
|
Chris@16
|
66 boost::system::error_code& ec);
|
Chris@16
|
67
|
Chris@16
|
68 BOOST_ASIO_DECL bool set_user_non_blocking(int d,
|
Chris@16
|
69 state_type& state, bool value, boost::system::error_code& ec);
|
Chris@16
|
70
|
Chris@16
|
71 BOOST_ASIO_DECL bool set_internal_non_blocking(int d,
|
Chris@16
|
72 state_type& state, bool value, boost::system::error_code& ec);
|
Chris@16
|
73
|
Chris@16
|
74 typedef iovec buf;
|
Chris@16
|
75
|
Chris@16
|
76 BOOST_ASIO_DECL std::size_t sync_read(int d, state_type state, buf* bufs,
|
Chris@16
|
77 std::size_t count, bool all_empty, boost::system::error_code& ec);
|
Chris@16
|
78
|
Chris@16
|
79 BOOST_ASIO_DECL bool non_blocking_read(int d, buf* bufs, std::size_t count,
|
Chris@16
|
80 boost::system::error_code& ec, std::size_t& bytes_transferred);
|
Chris@16
|
81
|
Chris@16
|
82 BOOST_ASIO_DECL std::size_t sync_write(int d, state_type state,
|
Chris@16
|
83 const buf* bufs, std::size_t count, bool all_empty,
|
Chris@16
|
84 boost::system::error_code& ec);
|
Chris@16
|
85
|
Chris@16
|
86 BOOST_ASIO_DECL bool non_blocking_write(int d,
|
Chris@16
|
87 const buf* bufs, std::size_t count,
|
Chris@16
|
88 boost::system::error_code& ec, std::size_t& bytes_transferred);
|
Chris@16
|
89
|
Chris@16
|
90 BOOST_ASIO_DECL int ioctl(int d, state_type& state, long cmd,
|
Chris@16
|
91 ioctl_arg_type* arg, boost::system::error_code& ec);
|
Chris@16
|
92
|
Chris@16
|
93 BOOST_ASIO_DECL int fcntl(int d, int cmd, boost::system::error_code& ec);
|
Chris@16
|
94
|
Chris@16
|
95 BOOST_ASIO_DECL int fcntl(int d, int cmd,
|
Chris@16
|
96 long arg, boost::system::error_code& ec);
|
Chris@16
|
97
|
Chris@16
|
98 BOOST_ASIO_DECL int poll_read(int d,
|
Chris@16
|
99 state_type state, boost::system::error_code& ec);
|
Chris@16
|
100
|
Chris@16
|
101 BOOST_ASIO_DECL int poll_write(int d,
|
Chris@16
|
102 state_type state, boost::system::error_code& ec);
|
Chris@16
|
103
|
Chris@16
|
104 } // namespace descriptor_ops
|
Chris@16
|
105 } // namespace detail
|
Chris@16
|
106 } // namespace asio
|
Chris@16
|
107 } // namespace boost
|
Chris@16
|
108
|
Chris@16
|
109 #include <boost/asio/detail/pop_options.hpp>
|
Chris@16
|
110
|
Chris@16
|
111 #if defined(BOOST_ASIO_HEADER_ONLY)
|
Chris@16
|
112 # include <boost/asio/detail/impl/descriptor_ops.ipp>
|
Chris@16
|
113 #endif // defined(BOOST_ASIO_HEADER_ONLY)
|
Chris@16
|
114
|
Chris@16
|
115 #endif // !defined(BOOST_ASIO_WINDOWS)
|
Chris@16
|
116 // && !defined(BOOST_ASIO_WINDOWS_RUNTIME)
|
Chris@16
|
117 // && !defined(__CYGWIN__)
|
Chris@16
|
118
|
Chris@16
|
119 #endif // BOOST_ASIO_DETAIL_DESCRIPTOR_OPS_HPP
|