]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/asio/detail/socket_ops.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / asio / detail / socket_ops.hpp
CommitLineData
7c673cae
FG
1//
2// detail/socket_ops.hpp
3// ~~~~~~~~~~~~~~~~~~~~~
4//
92f5a8d4 5// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7c673cae
FG
6//
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)
9//
10
11#ifndef BOOST_ASIO_DETAIL_SOCKET_OPS_HPP
12#define BOOST_ASIO_DETAIL_SOCKET_OPS_HPP
13
14#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15# pragma once
16#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
18#include <boost/asio/detail/config.hpp>
19
20#include <boost/system/error_code.hpp>
b32b8144 21#include <boost/asio/detail/memory.hpp>
7c673cae 22#include <boost/asio/detail/socket_types.hpp>
7c673cae
FG
23
24#include <boost/asio/detail/push_options.hpp>
25
26namespace boost {
27namespace asio {
28namespace detail {
29namespace socket_ops {
30
31// Socket state bits.
32enum
33{
34 // The user wants a non-blocking socket.
35 user_set_non_blocking = 1,
36
37 // The socket has been set non-blocking.
38 internal_non_blocking = 2,
39
40 // Helper "state" used to determine whether the socket is non-blocking.
41 non_blocking = user_set_non_blocking | internal_non_blocking,
42
43 // User wants connection_aborted errors, which are disabled by default.
44 enable_connection_aborted = 4,
45
46 // The user set the linger option. Needs to be checked when closing.
47 user_set_linger = 8,
48
49 // The socket is stream-oriented.
50 stream_oriented = 16,
51
52 // The socket is datagram-oriented.
53 datagram_oriented = 32,
54
55 // The socket may have been dup()-ed.
56 possible_dup = 64
57};
58
59typedef unsigned char state_type;
60
61struct noop_deleter { void operator()(void*) {} };
62typedef shared_ptr<void> shared_cancel_token_type;
63typedef weak_ptr<void> weak_cancel_token_type;
64
65#if !defined(BOOST_ASIO_WINDOWS_RUNTIME)
66
67BOOST_ASIO_DECL socket_type accept(socket_type s, socket_addr_type* addr,
68 std::size_t* addrlen, boost::system::error_code& ec);
69
70BOOST_ASIO_DECL socket_type sync_accept(socket_type s,
71 state_type state, socket_addr_type* addr,
72 std::size_t* addrlen, boost::system::error_code& ec);
73
74#if defined(BOOST_ASIO_HAS_IOCP)
75
76BOOST_ASIO_DECL void complete_iocp_accept(socket_type s,
77 void* output_buffer, DWORD address_length,
78 socket_addr_type* addr, std::size_t* addrlen,
79 socket_type new_socket, boost::system::error_code& ec);
80
81#else // defined(BOOST_ASIO_HAS_IOCP)
82
83BOOST_ASIO_DECL bool non_blocking_accept(socket_type s,
84 state_type state, socket_addr_type* addr, std::size_t* addrlen,
85 boost::system::error_code& ec, socket_type& new_socket);
86
87#endif // defined(BOOST_ASIO_HAS_IOCP)
88
89BOOST_ASIO_DECL int bind(socket_type s, const socket_addr_type* addr,
90 std::size_t addrlen, boost::system::error_code& ec);
91
92BOOST_ASIO_DECL int close(socket_type s, state_type& state,
93 bool destruction, boost::system::error_code& ec);
94
95BOOST_ASIO_DECL bool set_user_non_blocking(socket_type s,
96 state_type& state, bool value, boost::system::error_code& ec);
97
98BOOST_ASIO_DECL bool set_internal_non_blocking(socket_type s,
99 state_type& state, bool value, boost::system::error_code& ec);
100
101BOOST_ASIO_DECL int shutdown(socket_type s,
102 int what, boost::system::error_code& ec);
103
104BOOST_ASIO_DECL int connect(socket_type s, const socket_addr_type* addr,
105 std::size_t addrlen, boost::system::error_code& ec);
106
107BOOST_ASIO_DECL void sync_connect(socket_type s, const socket_addr_type* addr,
108 std::size_t addrlen, boost::system::error_code& ec);
109
110#if defined(BOOST_ASIO_HAS_IOCP)
111
112BOOST_ASIO_DECL void complete_iocp_connect(socket_type s,
113 boost::system::error_code& ec);
114
115#endif // defined(BOOST_ASIO_HAS_IOCP)
116
117BOOST_ASIO_DECL bool non_blocking_connect(socket_type s,
118 boost::system::error_code& ec);
119
120BOOST_ASIO_DECL int socketpair(int af, int type, int protocol,
121 socket_type sv[2], boost::system::error_code& ec);
122
123BOOST_ASIO_DECL bool sockatmark(socket_type s, boost::system::error_code& ec);
124
125BOOST_ASIO_DECL size_t available(socket_type s, boost::system::error_code& ec);
126
127BOOST_ASIO_DECL int listen(socket_type s,
128 int backlog, boost::system::error_code& ec);
129
130#if defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
131typedef WSABUF buf;
132#else // defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
133typedef iovec buf;
134#endif // defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
135
136BOOST_ASIO_DECL void init_buf(buf& b, void* data, size_t size);
137
138BOOST_ASIO_DECL void init_buf(buf& b, const void* data, size_t size);
139
140BOOST_ASIO_DECL signed_size_type recv(socket_type s, buf* bufs,
141 size_t count, int flags, boost::system::error_code& ec);
142
143BOOST_ASIO_DECL size_t sync_recv(socket_type s, state_type state, buf* bufs,
144 size_t count, int flags, bool all_empty, boost::system::error_code& ec);
145
146#if defined(BOOST_ASIO_HAS_IOCP)
147
148BOOST_ASIO_DECL void complete_iocp_recv(state_type state,
149 const weak_cancel_token_type& cancel_token, bool all_empty,
150 boost::system::error_code& ec, size_t bytes_transferred);
151
152#else // defined(BOOST_ASIO_HAS_IOCP)
153
154BOOST_ASIO_DECL bool non_blocking_recv(socket_type s,
155 buf* bufs, size_t count, int flags, bool is_stream,
156 boost::system::error_code& ec, size_t& bytes_transferred);
157
158#endif // defined(BOOST_ASIO_HAS_IOCP)
159
160BOOST_ASIO_DECL signed_size_type recvfrom(socket_type s, buf* bufs,
161 size_t count, int flags, socket_addr_type* addr,
162 std::size_t* addrlen, boost::system::error_code& ec);
163
164BOOST_ASIO_DECL size_t sync_recvfrom(socket_type s, state_type state,
165 buf* bufs, size_t count, int flags, socket_addr_type* addr,
166 std::size_t* addrlen, boost::system::error_code& ec);
167
168#if defined(BOOST_ASIO_HAS_IOCP)
169
170BOOST_ASIO_DECL void complete_iocp_recvfrom(
171 const weak_cancel_token_type& cancel_token,
172 boost::system::error_code& ec);
173
174#else // defined(BOOST_ASIO_HAS_IOCP)
175
176BOOST_ASIO_DECL bool non_blocking_recvfrom(socket_type s,
177 buf* bufs, size_t count, int flags,
178 socket_addr_type* addr, std::size_t* addrlen,
179 boost::system::error_code& ec, size_t& bytes_transferred);
180
181#endif // defined(BOOST_ASIO_HAS_IOCP)
182
183BOOST_ASIO_DECL signed_size_type recvmsg(socket_type s, buf* bufs,
184 size_t count, int in_flags, int& out_flags,
185 boost::system::error_code& ec);
186
187BOOST_ASIO_DECL size_t sync_recvmsg(socket_type s, state_type state,
188 buf* bufs, size_t count, int in_flags, int& out_flags,
189 boost::system::error_code& ec);
190
191#if defined(BOOST_ASIO_HAS_IOCP)
192
193BOOST_ASIO_DECL void complete_iocp_recvmsg(
194 const weak_cancel_token_type& cancel_token,
195 boost::system::error_code& ec);
196
197#else // defined(BOOST_ASIO_HAS_IOCP)
198
199BOOST_ASIO_DECL bool non_blocking_recvmsg(socket_type s,
200 buf* bufs, size_t count, int in_flags, int& out_flags,
201 boost::system::error_code& ec, size_t& bytes_transferred);
202
203#endif // defined(BOOST_ASIO_HAS_IOCP)
204
205BOOST_ASIO_DECL signed_size_type send(socket_type s, const buf* bufs,
206 size_t count, int flags, boost::system::error_code& ec);
207
208BOOST_ASIO_DECL size_t sync_send(socket_type s, state_type state,
209 const buf* bufs, size_t count, int flags,
210 bool all_empty, boost::system::error_code& ec);
211
212#if defined(BOOST_ASIO_HAS_IOCP)
213
214BOOST_ASIO_DECL void complete_iocp_send(
215 const weak_cancel_token_type& cancel_token,
216 boost::system::error_code& ec);
217
218#else // defined(BOOST_ASIO_HAS_IOCP)
219
220BOOST_ASIO_DECL bool non_blocking_send(socket_type s,
221 const buf* bufs, size_t count, int flags,
222 boost::system::error_code& ec, size_t& bytes_transferred);
223
224#endif // defined(BOOST_ASIO_HAS_IOCP)
225
226BOOST_ASIO_DECL signed_size_type sendto(socket_type s, const buf* bufs,
227 size_t count, int flags, const socket_addr_type* addr,
228 std::size_t addrlen, boost::system::error_code& ec);
229
230BOOST_ASIO_DECL size_t sync_sendto(socket_type s, state_type state,
231 const buf* bufs, size_t count, int flags, const socket_addr_type* addr,
232 std::size_t addrlen, boost::system::error_code& ec);
233
234#if !defined(BOOST_ASIO_HAS_IOCP)
235
236BOOST_ASIO_DECL bool non_blocking_sendto(socket_type s,
237 const buf* bufs, size_t count, int flags,
238 const socket_addr_type* addr, std::size_t addrlen,
239 boost::system::error_code& ec, size_t& bytes_transferred);
240
241#endif // !defined(BOOST_ASIO_HAS_IOCP)
242
243BOOST_ASIO_DECL socket_type socket(int af, int type, int protocol,
244 boost::system::error_code& ec);
245
246BOOST_ASIO_DECL int setsockopt(socket_type s, state_type& state,
247 int level, int optname, const void* optval,
248 std::size_t optlen, boost::system::error_code& ec);
249
250BOOST_ASIO_DECL int getsockopt(socket_type s, state_type state,
251 int level, int optname, void* optval,
252 size_t* optlen, boost::system::error_code& ec);
253
254BOOST_ASIO_DECL int getpeername(socket_type s, socket_addr_type* addr,
255 std::size_t* addrlen, bool cached, boost::system::error_code& ec);
256
257BOOST_ASIO_DECL int getsockname(socket_type s, socket_addr_type* addr,
258 std::size_t* addrlen, boost::system::error_code& ec);
259
260BOOST_ASIO_DECL int ioctl(socket_type s, state_type& state,
261 int cmd, ioctl_arg_type* arg, boost::system::error_code& ec);
262
263BOOST_ASIO_DECL int select(int nfds, fd_set* readfds, fd_set* writefds,
264 fd_set* exceptfds, timeval* timeout, boost::system::error_code& ec);
265
266BOOST_ASIO_DECL int poll_read(socket_type s,
b32b8144 267 state_type state, int msec, boost::system::error_code& ec);
7c673cae
FG
268
269BOOST_ASIO_DECL int poll_write(socket_type s,
b32b8144 270 state_type state, int msec, boost::system::error_code& ec);
7c673cae 271
b32b8144
FG
272BOOST_ASIO_DECL int poll_error(socket_type s,
273 state_type state, int msec, boost::system::error_code& ec);
274
275BOOST_ASIO_DECL int poll_connect(socket_type s,
276 int msec, boost::system::error_code& ec);
7c673cae
FG
277
278#endif // !defined(BOOST_ASIO_WINDOWS_RUNTIME)
279
280BOOST_ASIO_DECL const char* inet_ntop(int af, const void* src, char* dest,
281 size_t length, unsigned long scope_id, boost::system::error_code& ec);
282
283BOOST_ASIO_DECL int inet_pton(int af, const char* src, void* dest,
284 unsigned long* scope_id, boost::system::error_code& ec);
285
286BOOST_ASIO_DECL int gethostname(char* name,
287 int namelen, boost::system::error_code& ec);
288
289#if !defined(BOOST_ASIO_WINDOWS_RUNTIME)
290
291BOOST_ASIO_DECL boost::system::error_code getaddrinfo(const char* host,
292 const char* service, const addrinfo_type& hints,
293 addrinfo_type** result, boost::system::error_code& ec);
294
295BOOST_ASIO_DECL boost::system::error_code background_getaddrinfo(
296 const weak_cancel_token_type& cancel_token, const char* host,
297 const char* service, const addrinfo_type& hints,
298 addrinfo_type** result, boost::system::error_code& ec);
299
300BOOST_ASIO_DECL void freeaddrinfo(addrinfo_type* ai);
301
302BOOST_ASIO_DECL boost::system::error_code getnameinfo(
303 const socket_addr_type* addr, std::size_t addrlen,
304 char* host, std::size_t hostlen, char* serv,
305 std::size_t servlen, int flags, boost::system::error_code& ec);
306
307BOOST_ASIO_DECL boost::system::error_code sync_getnameinfo(
308 const socket_addr_type* addr, std::size_t addrlen,
309 char* host, std::size_t hostlen, char* serv,
310 std::size_t servlen, int sock_type, boost::system::error_code& ec);
311
312BOOST_ASIO_DECL boost::system::error_code background_getnameinfo(
313 const weak_cancel_token_type& cancel_token,
314 const socket_addr_type* addr, std::size_t addrlen,
315 char* host, std::size_t hostlen, char* serv,
316 std::size_t servlen, int sock_type, boost::system::error_code& ec);
317
318#endif // !defined(BOOST_ASIO_WINDOWS_RUNTIME)
319
320BOOST_ASIO_DECL u_long_type network_to_host_long(u_long_type value);
321
322BOOST_ASIO_DECL u_long_type host_to_network_long(u_long_type value);
323
324BOOST_ASIO_DECL u_short_type network_to_host_short(u_short_type value);
325
326BOOST_ASIO_DECL u_short_type host_to_network_short(u_short_type value);
327
328} // namespace socket_ops
329} // namespace detail
330} // namespace asio
331} // namespace boost
332
333#include <boost/asio/detail/pop_options.hpp>
334
335#if defined(BOOST_ASIO_HEADER_ONLY)
336# include <boost/asio/detail/impl/socket_ops.ipp>
337#endif // defined(BOOST_ASIO_HEADER_ONLY)
338
339#endif // BOOST_ASIO_DETAIL_SOCKET_OPS_HPP