27#include <system_error>
98 [[nodiscard]]
auto is_valid() const noexcept ->
bool {
return !
host.empty(); }
108 return host +
":" + std::to_string(
port);
115 return host == other.host &&
port == other.port;
122 return !(*
this == other);
159 std::function<void(std::span<const std::byte>)>
on_data;
183 std::function<void(std::string_view, std::span<const std::byte>)>
on_data;
189 std::function<void(std::string_view, std::error_code)>
on_error;
Callback functions for connection events.
std::function< void()> on_disconnected
Called when connection is closed.
std::function< void(std::span< const std::byte >)> on_data
Called when data is received (raw bytes)
std::function< void()> on_connected
Called when connection is established.
std::function< void(std::error_code)> on_error
Called when an error occurs.
Configuration options for connections.
bool keep_alive
Enable TCP keep-alive (where applicable)
std::chrono::milliseconds write_timeout
Write operation timeout (0 = no timeout)
std::chrono::milliseconds connect_timeout
Connection timeout duration (0 = no timeout)
bool no_delay
TCP no-delay (disable Nagle's algorithm)
std::chrono::milliseconds read_timeout
Read operation timeout (0 = no timeout)
Network endpoint information (host/port or URL)
endpoint_info(const std::string &url)
Constructs endpoint from URL (port extracted if present)
auto operator!=(const endpoint_info &other) const noexcept -> bool
Inequality comparison.
auto is_valid() const noexcept -> bool
Checks if the endpoint is valid (non-empty host)
endpoint_info(const std::string &h, uint16_t p)
Constructs endpoint from host and port.
std::string host
Hostname, IP address, or full URL.
uint16_t port
Port number (0 if embedded in URL)
endpoint_info()=default
Default constructor creates an empty endpoint.
auto operator==(const endpoint_info &other) const noexcept -> bool
Equality comparison.
endpoint_info(const char *url)
Constructs endpoint from C-string URL.
auto to_string() const -> std::string
Returns string representation of the endpoint.
endpoint_info(const char *h, uint16_t p)
Constructs endpoint from C-string host and port.
Callback functions for listener/server events.
std::function< void(std::string_view)> on_disconnect
Called when a connection is closed (connection ID)
std::function< void(std::string_view, std::error_code)> on_error
Called when an error occurs (connection ID, error)
std::function< void(std::string_view, std::span< const std::byte >)> on_data
Called when data is received from a connection (connection ID, data)
std::function< void(std::string_view)> on_accept
Called when a new connection is accepted (connection ID)