32#include <system_error>
47 std::invocable<F, std::error_code, std::size_t>;
78concept Socket =
requires(T& socket) {
79 { socket.close() } -> std::same_as<void>;
80 { socket.is_closed() } -> std::convertible_to<bool>;
113 T& socket, std::vector<uint8_t> data,
114 std::function<void(std::error_code, std::size_t)> send_handler,
115 std::function<void(
const std::vector<uint8_t>&)> recv_callback,
116 std::function<void(std::span<const uint8_t>)> recv_view_callback,
117 std::function<void(std::error_code)> error_callback) {
119 { socket.async_send(std::move(data), send_handler) } -> std::same_as<void>;
122 { socket.start_read() } -> std::same_as<void>;
123 { socket.stop_read() } -> std::same_as<void>;
126 { socket.set_receive_callback(recv_callback) } -> std::same_as<void>;
127 { socket.set_receive_callback_view(recv_view_callback) } -> std::same_as<void>;
128 { socket.set_error_callback(error_callback) } -> std::same_as<void>;
162 { socket.start_receive() } -> std::same_as<void>;
163 { socket.stop_receive() } -> std::same_as<void>;
167 socket.set_error_callback(std::function<
void(std::error_code)>{})
168 } -> std::same_as<void>;
187template <
typename T,
typename Endpo
int>
190 T& socket, std::vector<uint8_t> data,
const Endpoint& endpoint,
191 std::function<void(std::error_code, std::size_t)> handler) {
192 { socket.async_send_to(std::move(data), endpoint, handler) } -> std::same_as<void>;
222 T& socket, std::string text, std::vector<uint8_t> binary,
223 std::function<void(std::error_code, std::size_t)> handler) {
225 { socket.is_open() } -> std::convertible_to<bool>;
228 { socket.start_read() } -> std::same_as<void>;
232 socket.set_error_callback(std::function<
void(std::error_code)>{})
233 } -> std::same_as<void>;
265 T& socket, std::vector<uint8_t> data,
266 std::function<void(std::error_code, std::size_t)> handler,
267 std::function<void(
bool)> bp_callback) {
269 { socket.pending_bytes() } -> std::convertible_to<std::size_t>;
270 { socket.is_backpressure_active() } -> std::convertible_to<bool>;
273 { socket.try_send(std::move(data), handler) } -> std::convertible_to<bool>;
276 { socket.set_backpressure_callback(bp_callback) } -> std::same_as<void>;
301 { const_socket.metrics() };
302 { socket.reset_metrics() } -> std::same_as<void>;
356template <StreamSocket S>
375template <DatagramSocket S>
RAII guard for datagram socket receive loop.
datagram_receive_guard & operator=(const datagram_receive_guard &)=delete
datagram_receive_guard(S &socket)
datagram_receive_guard(const datagram_receive_guard &)=delete
~datagram_receive_guard()
RAII guard for socket read loop.
socket_read_guard(S &socket)
socket_read_guard(const socket_read_guard &)=delete
socket_read_guard & operator=(const socket_read_guard &)=delete
Standard completion handler signature for async operations.
Concept for sockets with backpressure control.
Datagram socket with specific endpoint type.
Concept for connectionless datagram sockets (UDP).
Error-only completion handler signature.
Concept for message-oriented sockets (WebSocket).
Concept for sockets with runtime metrics.
Concept for TLS/SSL-enabled sockets.
Base concept for all socket types.
Concept for connected stream sockets (TCP, TLS).
C++20 concepts for compile-time type validation in network_system.