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