| 1 |
|
|
1 |
|
|
| 2 |
|
// Copyright (c) 2026 Steve Gerbino
|
2 |
|
// Copyright (c) 2026 Steve Gerbino
|
| 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_NATIVE_DETAIL_EPOLL_EPOLL_SOCKET_HPP
|
10 |
|
#ifndef BOOST_COROSIO_NATIVE_DETAIL_EPOLL_EPOLL_SOCKET_HPP
|
| 11 |
|
#define BOOST_COROSIO_NATIVE_DETAIL_EPOLL_EPOLL_SOCKET_HPP
|
11 |
|
#define BOOST_COROSIO_NATIVE_DETAIL_EPOLL_EPOLL_SOCKET_HPP
|
| 12 |
|
|
12 |
|
|
| 13 |
|
#include <boost/corosio/detail/platform.hpp>
|
13 |
|
#include <boost/corosio/detail/platform.hpp>
|
| 14 |
|
|
14 |
|
|
| 15 |
|
#if BOOST_COROSIO_HAS_EPOLL
|
15 |
|
#if BOOST_COROSIO_HAS_EPOLL
|
| 16 |
|
|
16 |
|
|
| 17 |
|
#include <boost/corosio/tcp_socket.hpp>
|
17 |
|
#include <boost/corosio/tcp_socket.hpp>
|
| 18 |
|
#include <boost/capy/ex/executor_ref.hpp>
|
18 |
|
#include <boost/capy/ex/executor_ref.hpp>
|
| 19 |
|
#include <boost/corosio/detail/intrusive.hpp>
|
19 |
|
#include <boost/corosio/detail/intrusive.hpp>
|
| 20 |
|
|
20 |
|
|
| 21 |
|
#include <boost/corosio/native/detail/epoll/epoll_op.hpp>
|
21 |
|
#include <boost/corosio/native/detail/epoll/epoll_op.hpp>
|
| 22 |
|
|
22 |
|
|
| 23 |
|
|
23 |
|
|
| 24 |
|
|
24 |
|
|
| 25 |
|
namespace boost::corosio::detail {
|
25 |
|
namespace boost::corosio::detail {
|
| 26 |
|
|
26 |
|
|
| 27 |
|
class epoll_socket_service;
|
27 |
|
class epoll_socket_service;
|
| 28 |
|
|
28 |
|
|
| 29 |
|
/// Socket implementation for epoll backend.
|
29 |
|
/// Socket implementation for epoll backend.
|
| 30 |
|
|
30 |
|
|
| 31 |
|
: public tcp_socket::implementation
|
31 |
|
: public tcp_socket::implementation
|
| 32 |
|
, public std::enable_shared_from_this<epoll_socket>
|
32 |
|
, public std::enable_shared_from_this<epoll_socket>
|
| 33 |
|
, public intrusive_list<epoll_socket>::node
|
33 |
|
, public intrusive_list<epoll_socket>::node
|
| 34 |
|
|
34 |
|
|
| 35 |
|
friend class epoll_socket_service;
|
35 |
|
friend class epoll_socket_service;
|
| 36 |
|
|
36 |
|
|
| 37 |
|
|
37 |
|
|
| 38 |
|
explicit epoll_socket(epoll_socket_service& svc) noexcept;
|
38 |
|
explicit epoll_socket(epoll_socket_service& svc) noexcept;
|
| 39 |
|
~epoll_socket() override;
|
39 |
|
~epoll_socket() override;
|
| 40 |
|
|
40 |
|
|
| 41 |
|
std::coroutine_handle<> connect(
|
41 |
|
std::coroutine_handle<> connect(
|
| 42 |
|
|
42 |
|
|
| 43 |
|
|
43 |
|
|
| 44 |
|
|
44 |
|
|
| 45 |
|
|
45 |
|
|
| 46 |
|
std::error_code*) override;
|
46 |
|
std::error_code*) override;
|
| 47 |
|
|
47 |
|
|
| 48 |
|
std::coroutine_handle<> read_some(
|
48 |
|
std::coroutine_handle<> read_some(
|
| 49 |
|
|
49 |
|
|
| 50 |
|
|
50 |
|
|
| 51 |
|
|
51 |
|
|
| 52 |
|
|
52 |
|
|
| 53 |
|
|
53 |
|
|
| 54 |
|
|
54 |
|
|
| 55 |
|
|
55 |
|
|
| 56 |
|
std::coroutine_handle<> write_some(
|
56 |
|
std::coroutine_handle<> write_some(
|
| 57 |
|
|
57 |
|
|
| 58 |
|
|
58 |
|
|
| 59 |
|
|
59 |
|
|
| 60 |
|
|
60 |
|
|
| 61 |
|
|
61 |
|
|
| 62 |
|
|
62 |
|
|
| 63 |
|
|
63 |
|
|
| 64 |
|
std::error_code shutdown(tcp_socket::shutdown_type what) noexcept override;
|
64 |
|
std::error_code shutdown(tcp_socket::shutdown_type what) noexcept override;
|
| 65 |
|
|
65 |
|
|
| 66 |
|
native_handle_type native_handle() const noexcept override
|
66 |
|
native_handle_type native_handle() const noexcept override
|
| 67 |
|
|
67 |
|
|
| 68 |
|
|
68 |
|
|
| 69 |
|
|
69 |
|
|
| 70 |
|
|
70 |
|
|
| 71 |
|
|
71 |
|
|
| 72 |
|
std::error_code set_no_delay(bool value) noexcept override;
|
72 |
|
std::error_code set_no_delay(bool value) noexcept override;
|
| 73 |
|
bool no_delay(std::error_code& ec) const noexcept override;
|
73 |
|
bool no_delay(std::error_code& ec) const noexcept override;
|
| 74 |
|
|
74 |
|
|
| 75 |
|
std::error_code set_keep_alive(bool value) noexcept override;
|
75 |
|
std::error_code set_keep_alive(bool value) noexcept override;
|
| 76 |
|
bool keep_alive(std::error_code& ec) const noexcept override;
|
76 |
|
bool keep_alive(std::error_code& ec) const noexcept override;
|
| 77 |
|
|
77 |
|
|
| 78 |
|
std::error_code set_receive_buffer_size(int size) noexcept override;
|
78 |
|
std::error_code set_receive_buffer_size(int size) noexcept override;
|
| 79 |
|
int receive_buffer_size(std::error_code& ec) const noexcept override;
|
79 |
|
int receive_buffer_size(std::error_code& ec) const noexcept override;
|
| 80 |
|
|
80 |
|
|
| 81 |
|
std::error_code set_send_buffer_size(int size) noexcept override;
|
81 |
|
std::error_code set_send_buffer_size(int size) noexcept override;
|
| 82 |
|
int send_buffer_size(std::error_code& ec) const noexcept override;
|
82 |
|
int send_buffer_size(std::error_code& ec) const noexcept override;
|
| 83 |
|
|
83 |
|
|
| 84 |
|
std::error_code set_linger(bool enabled, int timeout) noexcept override;
|
84 |
|
std::error_code set_linger(bool enabled, int timeout) noexcept override;
|
| 85 |
|
tcp_socket::linger_options
|
85 |
|
tcp_socket::linger_options
|
| 86 |
|
linger(std::error_code& ec) const noexcept override;
|
86 |
|
linger(std::error_code& ec) const noexcept override;
|
| 87 |
|
|
87 |
|
|
| 88 |
|
endpoint local_endpoint() const noexcept override
|
88 |
|
endpoint local_endpoint() const noexcept override
|
| 89 |
|
|
89 |
|
|
| 90 |
|
|
90 |
|
|
| 91 |
|
|
91 |
|
|
| 92 |
|
endpoint remote_endpoint() const noexcept override
|
92 |
|
endpoint remote_endpoint() const noexcept override
|
| 93 |
|
|
93 |
|
|
| 94 |
|
|
94 |
|
|
| 95 |
|
|
95 |
|
|
| 96 |
|
bool is_open() const noexcept
|
96 |
|
bool is_open() const noexcept
|
| 97 |
|
|
97 |
|
|
| 98 |
|
|
98 |
|
|
| 99 |
|
|
99 |
|
|
| 100 |
|
void cancel() noexcept override;
|
100 |
|
void cancel() noexcept override;
|
| 101 |
|
void cancel_single_op(epoll_op& op) noexcept;
|
101 |
|
void cancel_single_op(epoll_op& op) noexcept;
|
| 102 |
|
void close_socket() noexcept;
|
102 |
|
void close_socket() noexcept;
|
| 103 |
|
void set_socket(int fd) noexcept
|
103 |
|
void set_socket(int fd) noexcept
|
| 104 |
|
|
104 |
|
|
| 105 |
|
|
105 |
|
|
| 106 |
|
|
106 |
|
|
| 107 |
|
void set_endpoints(endpoint local, endpoint remote) noexcept
|
107 |
|
void set_endpoints(endpoint local, endpoint remote) noexcept
|
| 108 |
|
|
108 |
|
|
| 109 |
|
|
109 |
|
|
| 110 |
|
remote_endpoint_ = remote;
|
110 |
|
remote_endpoint_ = remote;
|
| 111 |
|
|
111 |
|
|
| 112 |
|
|
112 |
|
|
| 113 |
|
|
113 |
|
|
| 114 |
|
|
114 |
|
|
| 115 |
|
|
115 |
|
|
| 116 |
|
|
116 |
|
|
| 117 |
|
/// Per-descriptor state for persistent epoll registration
|
117 |
|
/// Per-descriptor state for persistent epoll registration
|
| 118 |
|
descriptor_state desc_state_;
|
118 |
|
descriptor_state desc_state_;
|
| 119 |
|
|
119 |
|
|
| 120 |
|
|
120 |
|
|
| 121 |
|
epoll_socket_service& svc_;
|
121 |
|
epoll_socket_service& svc_;
|
| 122 |
|
|
122 |
|
|
| 123 |
|
endpoint local_endpoint_;
|
123 |
|
endpoint local_endpoint_;
|
| 124 |
|
endpoint remote_endpoint_;
|
124 |
|
endpoint remote_endpoint_;
|
| 125 |
|
|
125 |
|
|
| 126 |
|
|
126 |
|
|
| 127 |
|
|
127 |
|
|
| 128 |
|
|
128 |
|
|
| 129 |
|
|
129 |
|
|
| 130 |
|
bool& cancel_flag) noexcept;
|
130 |
|
bool& cancel_flag) noexcept;
|
| 131 |
|
|
131 |
|
|
| 132 |
|
|
132 |
|
|
| 133 |
|
friend struct epoll_connect_op;
|
133 |
|
friend struct epoll_connect_op;
|
| 134 |
|
|
134 |
|
|
| 135 |
|
|
135 |
|
|
| 136 |
|
} // namespace boost::corosio::detail
|
136 |
|
} // namespace boost::corosio::detail
|
| 137 |
|
|
137 |
|
|
| 138 |
|
#endif // BOOST_COROSIO_HAS_EPOLL
|
138 |
|
#endif // BOOST_COROSIO_HAS_EPOLL
|
| 139 |
|
|
139 |
|
|
| 140 |
|
#endif // BOOST_COROSIO_NATIVE_DETAIL_EPOLL_EPOLL_SOCKET_HPP
|
140 |
|
#endif // BOOST_COROSIO_NATIVE_DETAIL_EPOLL_EPOLL_SOCKET_HPP
|