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

Classes

class  connection_pool
 Manages a pool of reusable client connections to reduce connection overhead and improve performance. More...
 
class  http_client
 HTTP/1.1 client built on top of messaging_client. More...
 
struct  http_request_buffer
 Buffer for accumulating HTTP request data received in chunks. More...
 
struct  http_request_context
 Context for an HTTP request with parsed components. More...
 
struct  http_route
 Route definition with pattern matching and handler. More...
 
class  http_server
 HTTP/1.1 server built on top of messaging_server. More...
 
struct  http_url
 Parsed URL components. More...
 
class  messaging_client
 A basic TCP client that connects to a remote host, sends/receives data using asynchronous operations, and can apply a pipeline for transformations. More...
 
class  messaging_quic_client
 A QUIC client that provides reliable, multiplexed communication. More...
 
class  messaging_quic_server
 A QUIC server that manages incoming client connections. More...
 
class  messaging_server
 A server class that manages incoming TCP connections, creating messaging_session instances for each accepted socket. More...
 
class  messaging_session
 Represents a client session on the server. More...
 
class  messaging_udp_client
 A UDP client that sends datagrams to a target endpoint and can receive responses. More...
 
class  messaging_udp_server
 A UDP server that receives datagrams and routes them based on sender endpoint. More...
 
class  messaging_ws_client
 High-level WebSocket client with automatic connection management. More...
 
class  messaging_ws_server
 High-level WebSocket server with connection management. More...
 
class  network_context
 Global context for shared network system resources. More...
 
struct  packet_header
 
struct  packet_info
 
struct  quic_client_config
 Configuration options for QUIC client. More...
 
struct  quic_connection_stats
 Statistics for a QUIC connection. More...
 
struct  quic_server_config
 Configuration options for QUIC server. More...
 
class  reliable_udp_client
 A UDP client with optional reliability layer for configurable delivery guarantees. More...
 
struct  reliable_udp_stats
 Statistics for monitoring reliable UDP connection performance. More...
 
class  secure_messaging_client
 A secure client for establishing TLS/SSL encrypted TCP connections to a server. More...
 
class  secure_messaging_server
 A secure server class that manages incoming TLS/SSL encrypted TCP connections, creating secure_session instances for each accepted socket. More...
 
class  secure_messaging_udp_client
 A secure UDP client using DTLS (Datagram TLS) for encrypted communication. More...
 
class  secure_messaging_udp_server
 A secure UDP server using DTLS (Datagram TLS) for encrypted communication. More...
 
class  session_concept
 Type-erased interface for session management. More...
 
struct  session_config
 Configuration for session management. More...
 
class  session_handle
 Value-semantic wrapper for type-erased sessions. More...
 
struct  session_info
 Session info struct for backward compatibility. More...
 
struct  session_info_base
 Wrapper for session with optional activity tracking. More...
 
struct  session_info_base< SessionType, false >
 Specialization without activity tracking (minimal overhead) More...
 
struct  session_info_base< SessionType, true >
 Specialization with activity tracking enabled. More...
 
class  session_manager
 Thread-safe TCP session lifecycle management with backpressure. More...
 
class  session_manager_base
 Thread-safe session lifecycle management template. More...
 
class  session_model
 Template that wraps concrete session types to implement session_concept. More...
 
struct  session_traits
 Customization point for session manager behavior. More...
 
struct  session_traits< session::messaging_session >
 Session traits specialization for TCP messaging sessions. More...
 
struct  session_traits< ws_connection >
 Session traits specialization for WebSocket connections. More...
 
struct  ssl_config
 SSL/TLS configuration structure. More...
 
class  unified_messaging_client
 Unified TCP client template parameterized by protocol and TLS policy. More...
 
class  unified_messaging_server
 Unified TCP server template parameterized by protocol and TLS policy. More...
 
struct  unified_session_config
 Configuration for unified session management. More...
 
class  unified_session_manager
 Type-erased session manager that handles any session type. More...
 
class  unified_udp_messaging_client
 Unified UDP client template parameterized by TLS policy. More...
 
class  unified_udp_messaging_server
 Unified UDP server template parameterized by TLS policy. More...
 
struct  ws_client_config
 Configuration for WebSocket client. More...
 
class  ws_connection
 Represents a WebSocket connection to a client. More...
 
class  ws_connection_impl
 
struct  ws_server_config
 Configuration for WebSocket server. More...
 
class  ws_session_manager
 Thread-safe WebSocket session lifecycle management. More...
 

Typedefs

using tcp = asio::ip::tcp
 
using udp = asio::ip::udp
 
template<typename SessionType >
using session_info_t
 Convenience alias that selects the appropriate session_info_base based on session_traits.
 
using tcp_client = unified_messaging_client<protocol::tcp_protocol, policy::no_tls>
 Type alias for plain TCP client.
 
using tcp_server = unified_messaging_server<protocol::tcp_protocol, policy::no_tls>
 Type alias for plain TCP server.
 
using udp_client = unified_udp_messaging_client<policy::no_tls>
 Type alias for plain UDP client.
 
using udp_server = unified_udp_messaging_server<policy::no_tls>
 Type alias for plain UDP server.
 
using quic_client = messaging_quic_client
 Type alias for QUIC client.
 
using secure_quic_client = messaging_quic_client
 Type alias for secure QUIC client (same as quic_client).
 
using quic_server = messaging_quic_server
 Type alias for QUIC server.
 
using secure_quic_server = messaging_quic_server
 Type alias for secure QUIC server (same as quic_server).
 
using http_handler = std::function<internal::http_response(const http_request_context& ctx)>
 Handler function for HTTP requests.
 
using error_handler = std::function<internal::http_response(const internal::http_error& error)>
 Handler function for HTTP errors.
 
using ws_client = messaging_ws_client
 Type alias for WebSocket client (plain).
 
using secure_ws_client = messaging_ws_client
 Type alias for secure WebSocket client (WSS).
 
using ws_server = messaging_ws_server
 Type alias for WebSocket server (plain).
 
using secure_ws_server = messaging_ws_server
 Type alias for secure WebSocket server (WSS).
 
using kcenon::network::core::connection_callback = std::function<void()>
 Callback type aliases for messaging.
 
using kcenon::network::core::disconnection_callback = std::function<void()>
 
using kcenon::network::core::error_callback = std::function<void(const std::string&)>
 
using kcenon::network::core::data_callback = std::function<void(std::span<const uint8_t>)>
 

Enumerations

enum class  reliability_mode { unreliable , reliable_ordered , reliable_unordered , sequenced }
 Defines the reliability level for UDP packet transmission. More...
 
enum class  kcenon::network::core::connection_state { disconnected , connecting , connected , disconnecting }
 Connection state enumeration. More...
 
enum class  kcenon::network::core::ssl_protocol { tls_1_2 , tls_1_3 , dtls_1_2 , dtls_1_3 }
 SSL/TLS protocol version enumeration. More...
 
enum class  kcenon::network::core::ssl_verify_mode { none , peer , fail_if_no_peer_cert , client_once }
 SSL verification mode. More...
 

Functions

template<typename SessionType >
auto make_session_handle (std::shared_ptr< SessionType > session) -> session_handle
 Factory function to create a session_handle.
 
template<typename SessionType >
auto make_session_model (std::shared_ptr< SessionType > session) -> std::unique_ptr< session_concept >
 Factory function to create a session_model.
 
constexpr std::string_view kcenon::network::core::to_string (connection_state state) noexcept
 Convert connection state to string.
 

Typedef Documentation

◆ connection_callback

using kcenon::network::core::connection_callback = std::function<void()>
export

Callback type aliases for messaging.

Definition at line 410 of file core.cppm.

◆ data_callback

using kcenon::network::core::data_callback = std::function<void(std::span<const uint8_t>)>
export

Definition at line 413 of file core.cppm.

◆ disconnection_callback

using kcenon::network::core::disconnection_callback = std::function<void()>
export

Definition at line 411 of file core.cppm.

◆ error_callback

using kcenon::network::core::error_callback = std::function<void(const std::string&)>
export

Definition at line 412 of file core.cppm.

◆ error_handler

Handler function for HTTP errors.

Parameters
errorError details
Returns
HTTP response to send back to client

Definition at line 122 of file http_server.h.

◆ http_handler

Handler function for HTTP requests.

Parameters
ctxRequest context with parsed request and parameters
Returns
HTTP response to send back to client

Definition at line 113 of file http_server.h.

◆ quic_client

Type alias for QUIC client.

QUIC (RFC 9000) provides reliable, multiplexed, secure transport. Note: QUIC always uses TLS 1.3 encryption - there is no "plain" QUIC variant.

auto client = std::make_shared<quic_client>("client1");
client->start_client("localhost", 4433);

Definition at line 609 of file quic_client.h.

◆ quic_server

Type alias for QUIC server.

QUIC (RFC 9000) provides reliable, multiplexed, secure transport. Note: QUIC always uses TLS 1.3 encryption - there is no "plain" QUIC variant.

auto server = std::make_shared<quic_server>("server1");
quic_server_config config{.cert_file = "cert.pem", .key_file = "key.pem"};
server->start_server(4433, config);
tracing_config config
Definition exporters.cpp:29
Configuration options for QUIC server.
Definition quic_server.h:63

Definition at line 563 of file quic_server.h.

◆ secure_quic_client

Type alias for secure QUIC client (same as quic_client).

QUIC inherently uses TLS 1.3 for all connections, so this alias is provided for API consistency with other protocol patterns. Both quic_client and secure_quic_client refer to the same implementation.

// Both are equivalent:
auto client1 = std::make_shared<quic_client>("client1");
auto client2 = std::make_shared<secure_quic_client>("client2");

Definition at line 624 of file quic_client.h.

◆ secure_quic_server

Type alias for secure QUIC server (same as quic_server).

QUIC inherently uses TLS 1.3 for all connections, so this alias is provided for API consistency with other protocol patterns. Both quic_server and secure_quic_server refer to the same implementation.

// Both are equivalent:
auto server1 = std::make_shared<quic_server>("server1");
auto server2 = std::make_shared<secure_quic_server>("server2");

Definition at line 578 of file quic_server.h.

◆ secure_ws_client

Type alias for secure WebSocket client (WSS).

WebSocket Secure (WSS) uses TLS encryption over the TCP connection. Note: The actual TLS configuration is handled at the connection level.

auto wss_client = std::make_shared<secure_ws_client>("client1");
wss_client->start_client("localhost", 443, "/ws");
Note
Currently uses the same implementation as messaging_ws_client. TLS is negotiated via the wss:// scheme or port configuration.

Definition at line 452 of file websocket_client.h.

◆ secure_ws_server

Type alias for secure WebSocket server (WSS).

WebSocket Secure (WSS) uses TLS encryption over the TCP connection. Note: TLS configuration should be handled at the server setup level.

auto wss_server = std::make_shared<secure_ws_server>("server1");
wss_server->start_server(8443, "/ws");
Note
Currently uses the same implementation as messaging_ws_server. TLS should be configured via server configuration options.

Definition at line 535 of file websocket_server.h.

◆ session_info_t

template<typename SessionType >
using kcenon::network::core::session_info_t
Initial value:
session_info_base<SessionType,
session_traits<SessionType>::has_activity_tracking>

Convenience alias that selects the appropriate session_info_base based on session_traits.

Template Parameters
SessionTypeThe session type to wrap

Definition at line 81 of file session_info.h.

◆ tcp

typedef asio::ip::tcp kcenon::network::core::tcp = asio::ip::tcp

Definition at line 18 of file messaging_client.cpp.

◆ tcp_client

Type alias for plain TCP client.

Equivalent to: messaging_client<tcp_protocol, no_tls>

Definition at line 311 of file unified_messaging_client.h.

◆ tcp_server

Type alias for plain TCP server.

Equivalent to: unified_messaging_server<tcp_protocol, no_tls>

Definition at line 319 of file unified_messaging_server.h.

◆ udp

typedef asio::ip::udp kcenon::network::core::udp = asio::ip::udp

Definition at line 12 of file messaging_udp_client.cpp.

◆ udp_client

Type alias for plain UDP client.

Definition at line 308 of file unified_udp_messaging_client.h.

◆ udp_server

Type alias for plain UDP server.

Definition at line 335 of file unified_udp_messaging_server.h.

◆ ws_client

Type alias for WebSocket client (plain).

Provides consistent naming with the unified template pattern. WebSocket uses HTTP upgrade over TCP, optionally secured via TLS (WSS).

auto ws_client = std::make_shared<ws_client>("client1");
ws_client->start_client("localhost", 80, "/ws");
High-level WebSocket client with automatic connection management.
auto start_client(const ws_client_config &config) -> VoidResult
Starts the client with full configuration.

Definition at line 436 of file websocket_client.h.

◆ ws_server

Type alias for WebSocket server (plain).

Provides consistent naming with the unified template pattern. WebSocket uses HTTP upgrade over TCP, optionally secured via TLS (WSS).

auto ws_server = std::make_shared<ws_server>("server1");
ws_server->start_server(8080, "/ws");
High-level WebSocket server with connection management.
auto start_server(const ws_server_config &config) -> VoidResult
Starts the server with full configuration.

Definition at line 519 of file websocket_server.h.

Enumeration Type Documentation

◆ connection_state

enum class kcenon::network::core::connection_state
exportstrong

Connection state enumeration.

Enumerator
disconnected 
connecting 
connected 
disconnecting 

Definition at line 385 of file core.cppm.

385 {
387 connecting,
388 connected,
389 disconnecting
390};

◆ reliability_mode

Defines the reliability level for UDP packet transmission.

Enumerator
unreliable 

Pure UDP - no guarantees (lowest latency)

reliable_ordered 

TCP-like reliability with in-order delivery

reliable_unordered 

Guaranteed delivery without ordering

sequenced 

Drop old packets, no retransmission (for real-time)

Definition at line 27 of file reliable_udp_client.h.

◆ ssl_protocol

enum class kcenon::network::core::ssl_protocol
exportstrong

SSL/TLS protocol version enumeration.

Enumerator
tls_1_2 

TLS 1.2.

tls_1_3 

TLS 1.3 (recommended)

dtls_1_2 

DTLS 1.2 for UDP.

dtls_1_3 

DTLS 1.3 for UDP.

Definition at line 59 of file ssl.cppm.

59 {
60 tls_1_2,
61 tls_1_3,
62 dtls_1_2,
64};

◆ ssl_verify_mode

enum class kcenon::network::core::ssl_verify_mode
exportstrong

SSL verification mode.

Enumerator
none 

No verification.

peer 

Verify peer certificate.

fail_if_no_peer_cert 

Fail if no peer certificate.

client_once 

Request client certificate once.

Definition at line 69 of file ssl.cppm.

69 {
70 none,
71 peer,
74};
@ client_once
Request client certificate once.
@ fail_if_no_peer_cert
Fail if no peer certificate.
@ peer
Verify peer certificate.

Function Documentation

◆ make_session_handle()

template<typename SessionType >
auto kcenon::network::core::make_session_handle ( std::shared_ptr< SessionType > session) -> session_handle
nodiscard

Factory function to create a session_handle.

Template Parameters
SessionTypeThe concrete session type
Parameters
sessionShared pointer to the session
Returns
session_handle wrapping the session

Definition at line 313 of file session_handle.h.

314 {
315 return session_handle(std::move(session));
316}
Value-semantic wrapper for type-erased sessions.

◆ make_session_model()

template<typename SessionType >
auto kcenon::network::core::make_session_model ( std::shared_ptr< SessionType > session) -> std::unique_ptr<session_concept>
nodiscard

Factory function to create a session_model.

Template Parameters
SessionTypeThe concrete session type
Parameters
sessionShared pointer to the session
Returns
Unique pointer to the type-erased session_concept

Definition at line 291 of file session_model.h.

292 {
293 // Explicitly construct unique_ptr<session_concept> from raw pointer
294 // This ensures proper polymorphic conversion
295 return std::unique_ptr<session_concept>(
296 new session_model<SessionType>(std::move(session)));
297}
Template that wraps concrete session types to implement session_concept.

◆ to_string()

std::string_view kcenon::network::core::to_string ( connection_state state)
constexprexportnoexcept

Convert connection state to string.

Parameters
stateThe connection state
Returns
String representation

Definition at line 397 of file core.cppm.

397 {
398 switch (state) {
399 case connection_state::disconnected: return "disconnected";
400 case connection_state::connecting: return "connecting";
401 case connection_state::connected: return "connected";
402 case connection_state::disconnecting: return "disconnecting";
403 default: return "unknown";
404 }
405}

References connected, connecting, disconnected, and disconnecting.

Referenced by kcenon::network::core::secure_messaging_udp_server::endpoint_hash::operator()().

Here is the caller graph for this function: