Network System 0.1.1
High-performance modular networking library for scalable client-server applications
Loading...
Searching...
No Matches
kcenon::network::concepts::BackpressureAwareSocket Concept Reference

Concept for sockets with backpressure control. More...

#include <socket_concepts.h>

Concept definition

template<typename T>
T& socket, std::vector<uint8_t> data,
std::function<void(std::error_code, std::size_t)> handler,
std::function<void(bool)> bp_callback) {
{ socket.pending_bytes() } -> std::convertible_to<std::size_t>;
{ socket.is_backpressure_active() } -> std::convertible_to<bool>;
{ socket.try_send(std::move(data), handler) } -> std::convertible_to<bool>;
{ socket.set_backpressure_callback(bp_callback) } -> std::same_as<void>;
}
Concept for sockets with backpressure control.
Concept for connected stream sockets (TCP, TLS).

Detailed Description

Concept for sockets with backpressure control.

Sockets satisfying this concept provide flow control mechanisms to prevent memory exhaustion when sending to slow receivers.

Types satisfying this concept: tcp_socket (with backpressure enabled)

Example usage:

template<BackpressureAwareSocket S>
void send_with_flow_control(S& socket, std::vector<uint8_t> data) {
if (socket.is_backpressure_active()) {
// Queue or drop data
return;
}
if (!socket.try_send(std::move(data), handler)) {
// Backpressure limit reached
}
}

Definition at line 264 of file socket_concepts.h.