Concept for connected stream sockets (TCP, TLS).
More...
#include <socket_concepts.h>
template<typename T>
T& socket, std::vector<uint8_t> data,
std::function<void(std::error_code, std::size_t)> send_handler,
std::function<void(const std::vector<uint8_t>&)> recv_callback,
std::function<void(std::span<const uint8_t>)> recv_view_callback,
std::function<void(std::error_code)> error_callback) {
{ socket.async_send(std::move(data), send_handler) } -> std::same_as<void>;
{ socket.start_read() } -> std::same_as<void>;
{ socket.stop_read() } -> std::same_as<void>;
{ socket.set_receive_callback(recv_callback) } -> std::same_as<void>;
{ socket.set_receive_callback_view(recv_view_callback) } -> std::same_as<void>;
{ socket.set_error_callback(error_callback) } -> std::same_as<void>;
}
Base concept for all socket types.
Concept for connected stream sockets (TCP, TLS).
Concept for connected stream sockets (TCP, TLS).
Stream sockets provide bidirectional byte stream communication. They support:
- Asynchronous send with completion handler
- Continuous read loop via start_read/stop_read
- Receive and error callback registration
Types satisfying this concept: tcp_socket, secure_tcp_socket
Example usage:
template<StreamSocket S>
void send_message(S& socket, std::vector<uint8_t> data) {
socket.async_send(std::move(data), [](std::error_code ec, size_t n) {
if (ec) {
}
});
}
Definition at line 112 of file socket_concepts.h.