| 1 |
|
|
1 |
|
|
| 2 |
|
// Copyright (c) 2026 Michael Vandeberg
|
2 |
|
// Copyright (c) 2026 Michael Vandeberg
|
| 3 |
|
|
3 |
|
|
| 4 |
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
4 |
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
| 5 |
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
5 |
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
| 6 |
|
|
6 |
|
|
| 7 |
|
// Official repository: https://github.com/cppalliance/corosio
|
7 |
|
// Official repository: https://github.com/cppalliance/corosio
|
| 8 |
|
|
8 |
|
|
| 9 |
|
|
9 |
|
|
| 10 |
|
#ifndef BOOST_COROSIO_DETAIL_LOCAL_STREAM_ACCEPTOR_SERVICE_HPP
|
10 |
|
#ifndef BOOST_COROSIO_DETAIL_LOCAL_STREAM_ACCEPTOR_SERVICE_HPP
|
| 11 |
|
#define BOOST_COROSIO_DETAIL_LOCAL_STREAM_ACCEPTOR_SERVICE_HPP
|
11 |
|
#define BOOST_COROSIO_DETAIL_LOCAL_STREAM_ACCEPTOR_SERVICE_HPP
|
| 12 |
|
|
12 |
|
|
| 13 |
|
#include <boost/corosio/detail/config.hpp>
|
13 |
|
#include <boost/corosio/detail/config.hpp>
|
| 14 |
|
#include <boost/corosio/local_stream_acceptor.hpp>
|
14 |
|
#include <boost/corosio/local_stream_acceptor.hpp>
|
| 15 |
|
#include <boost/corosio/local_endpoint.hpp>
|
15 |
|
#include <boost/corosio/local_endpoint.hpp>
|
| 16 |
|
#include <boost/capy/ex/execution_context.hpp>
|
16 |
|
#include <boost/capy/ex/execution_context.hpp>
|
| 17 |
|
|
17 |
|
|
| 18 |
|
|
18 |
|
|
| 19 |
|
namespace boost::corosio::detail {
|
19 |
|
namespace boost::corosio::detail {
|
| 20 |
|
|
20 |
|
|
| 21 |
|
/** Abstract local stream acceptor service base class.
|
21 |
|
/** Abstract local stream acceptor service base class.
|
| 22 |
|
|
22 |
|
|
| 23 |
|
Concrete implementations (epoll, select, kqueue, IOCP)
|
23 |
|
Concrete implementations (epoll, select, kqueue, IOCP)
|
| 24 |
|
inherit from this class and provide platform-specific
|
24 |
|
inherit from this class and provide platform-specific
|
| 25 |
|
acceptor operations for local (Unix domain) sockets.
|
25 |
|
acceptor operations for local (Unix domain) sockets.
|
| 26 |
|
|
26 |
|
|
| 27 |
|
Instances are looked up via key_type in the
|
27 |
|
Instances are looked up via key_type in the
|
| 28 |
|
execution_context. The backend's construct() function
|
28 |
|
execution_context. The backend's construct() function
|
| 29 |
|
installs the appropriate derived service.
|
29 |
|
installs the appropriate derived service.
|
| 30 |
|
|
30 |
|
|
| 31 |
|
All errors are reported via the returned std::error_code;
|
31 |
|
All errors are reported via the returned std::error_code;
|
| 32 |
|
these methods do not throw.
|
32 |
|
these methods do not throw.
|
| 33 |
|
|
33 |
|
|
| 34 |
|
class BOOST_COROSIO_DECL local_stream_acceptor_service
|
34 |
|
class BOOST_COROSIO_DECL local_stream_acceptor_service
|
| 35 |
|
: public capy::execution_context::service
|
35 |
|
: public capy::execution_context::service
|
| 36 |
|
, public io_object::io_service
|
36 |
|
, public io_object::io_service
|
| 37 |
|
|
37 |
|
|
| 38 |
|
|
38 |
|
|
| 39 |
|
/// Identifies this service for execution_context lookup.
|
39 |
|
/// Identifies this service for execution_context lookup.
|
| 40 |
|
using key_type = local_stream_acceptor_service;
|
40 |
|
using key_type = local_stream_acceptor_service;
|
| 41 |
|
|
41 |
|
|
| 42 |
|
/** Create the acceptor socket.
|
42 |
|
/** Create the acceptor socket.
|
| 43 |
|
|
43 |
|
|
| 44 |
|
@param impl The acceptor implementation to open.
|
44 |
|
@param impl The acceptor implementation to open.
|
| 45 |
|
Must not already represent an open socket.
|
45 |
|
Must not already represent an open socket.
|
| 46 |
|
@param family Address family for local IPC.
|
46 |
|
@param family Address family for local IPC.
|
| 47 |
|
@param type Socket type for stream sockets.
|
47 |
|
@param type Socket type for stream sockets.
|
| 48 |
|
@param protocol Protocol number (typically 0).
|
48 |
|
@param protocol Protocol number (typically 0).
|
| 49 |
|
@return Error code on failure, empty on success.
|
49 |
|
@return Error code on failure, empty on success.
|
| 50 |
|
|
50 |
|
|
| 51 |
|
virtual std::error_code open_acceptor_socket(
|
51 |
|
virtual std::error_code open_acceptor_socket(
|
| 52 |
|
local_stream_acceptor::implementation& impl,
|
52 |
|
local_stream_acceptor::implementation& impl,
|
| 53 |
|
|
53 |
|
|
| 54 |
|
|
54 |
|
|
| 55 |
|
|
55 |
|
|
| 56 |
|
|
56 |
|
|
| 57 |
|
/** Bind an open acceptor to a local endpoint.
|
57 |
|
/** Bind an open acceptor to a local endpoint.
|
| 58 |
|
|
58 |
|
|
| 59 |
|
@pre @p impl was opened via open_acceptor_socket().
|
59 |
|
@pre @p impl was opened via open_acceptor_socket().
|
| 60 |
|
@param impl The acceptor implementation to bind.
|
60 |
|
@param impl The acceptor implementation to bind.
|
| 61 |
|
@param ep The local endpoint (path) to bind to.
|
61 |
|
@param ep The local endpoint (path) to bind to.
|
| 62 |
|
Copied; need not remain valid after the call.
|
62 |
|
Copied; need not remain valid after the call.
|
| 63 |
|
@return Error code on failure, empty on success.
|
63 |
|
@return Error code on failure, empty on success.
|
| 64 |
|
|
64 |
|
|
| 65 |
|
virtual std::error_code bind_acceptor(
|
65 |
|
virtual std::error_code bind_acceptor(
|
| 66 |
|
local_stream_acceptor::implementation& impl,
|
66 |
|
local_stream_acceptor::implementation& impl,
|
| 67 |
|
|
67 |
|
|
| 68 |
|
|
68 |
|
|
| 69 |
|
/** Start listening for incoming connections.
|
69 |
|
/** Start listening for incoming connections.
|
| 70 |
|
|
70 |
|
|
| 71 |
|
@pre @p impl was bound via bind_acceptor().
|
71 |
|
@pre @p impl was bound via bind_acceptor().
|
| 72 |
|
@param impl The acceptor implementation to listen on.
|
72 |
|
@param impl The acceptor implementation to listen on.
|
| 73 |
|
@param backlog The maximum pending connection queue length.
|
73 |
|
@param backlog The maximum pending connection queue length.
|
| 74 |
|
@return Error code on failure, empty on success.
|
74 |
|
@return Error code on failure, empty on success.
|
| 75 |
|
|
75 |
|
|
| 76 |
|
virtual std::error_code listen_acceptor(
|
76 |
|
virtual std::error_code listen_acceptor(
|
| 77 |
|
local_stream_acceptor::implementation& impl,
|
77 |
|
local_stream_acceptor::implementation& impl,
|
| 78 |
|
|
78 |
|
|
| 79 |
|
|
79 |
|
|
| 80 |
|
|
80 |
|
|
| 81 |
|
local_stream_acceptor_service() = default;
|
81 |
|
local_stream_acceptor_service() = default;
|
| 82 |
|
~local_stream_acceptor_service() override = default;
|
82 |
|
~local_stream_acceptor_service() override = default;
|
| 83 |
|
|
83 |
|
|
| 84 |
|
|
84 |
|
|
| 85 |
|
} // namespace boost::corosio::detail
|
85 |
|
} // namespace boost::corosio::detail
|
| 86 |
|
|
86 |
|
|
| 87 |
|
#endif // BOOST_COROSIO_DETAIL_LOCAL_STREAM_ACCEPTOR_SERVICE_HPP
|
87 |
|
#endif // BOOST_COROSIO_DETAIL_LOCAL_STREAM_ACCEPTOR_SERVICE_HPP
|