|
Network System 0.1.1
High-performance modular networking library for scalable client-server applications
|
Core interface for active network connections. More...
#include <i_connection.h>


Public Member Functions | |
| ~i_connection () override=default | |
| Virtual destructor. | |
| i_connection (const i_connection &)=delete | |
| i_connection & | operator= (const i_connection &)=delete |
| i_connection (i_connection &&)=default | |
| i_connection & | operator= (i_connection &&)=default |
| virtual auto | connect (const endpoint_info &endpoint) -> VoidResult=0 |
| Connects to a remote endpoint using host/port. | |
| virtual auto | connect (std::string_view url) -> VoidResult=0 |
| Connects to a remote endpoint using URL. | |
| virtual auto | close () noexcept -> void=0 |
| Closes the connection gracefully. | |
| virtual auto | set_callbacks (connection_callbacks callbacks) -> void=0 |
| Sets all connection callbacks at once. | |
| virtual auto | set_options (connection_options options) -> void=0 |
| Sets connection options. | |
| virtual auto | set_timeout (std::chrono::milliseconds timeout) -> void=0 |
| Sets the connection timeout. | |
| virtual auto | is_connecting () const noexcept -> bool=0 |
| Checks if the connection is in the process of connecting. | |
| virtual auto | wait_for_stop () -> void=0 |
| Blocks until the component has stopped. | |
Public Member Functions inherited from kcenon::network::unified::i_transport | |
| virtual | ~i_transport ()=default |
| Virtual destructor for proper cleanup of derived classes. | |
| i_transport (const i_transport &)=delete | |
| i_transport & | operator= (const i_transport &)=delete |
| i_transport (i_transport &&)=default | |
| i_transport & | operator= (i_transport &&)=default |
| virtual auto | send (std::span< const std::byte > data) -> VoidResult=0 |
| Sends raw data to the remote endpoint. | |
| virtual auto | send (std::vector< uint8_t > &&data) -> VoidResult=0 |
| Sends data from a uint8_t vector. | |
| virtual auto | is_connected () const noexcept -> bool=0 |
| Checks if the transport is currently connected. | |
| virtual auto | id () const noexcept -> std::string_view=0 |
| Gets the unique identifier for this transport/connection. | |
| virtual auto | remote_endpoint () const noexcept -> endpoint_info=0 |
| Gets the remote endpoint information. | |
| virtual auto | local_endpoint () const noexcept -> endpoint_info=0 |
| Gets the local endpoint information. | |
Protected Member Functions | |
| i_connection ()=default | |
| Default constructor (only for derived classes) | |
Protected Member Functions inherited from kcenon::network::unified::i_transport | |
| i_transport ()=default | |
| Default constructor (only for derived classes) | |
Core interface for active network connections.
This interface extends i_transport with connection lifecycle operations. It represents:
By inheriting from i_transport, i_connection provides a unified interface for data transfer while adding connection-specific operations. This allows code that only needs to send/receive data to work with just i_transport, while connection management code uses i_connection.
All public methods must be thread-safe.
Definition at line 88 of file i_connection.h.
|
overridedefault |
Virtual destructor.
Closing the connection is implicit when the i_connection is destroyed.
|
delete |
|
default |
|
protecteddefault |
Default constructor (only for derived classes)
|
pure virtualnoexcept |
Closes the connection gracefully.
Thread-safe. Safe to call multiple times.
After close(), is_connected() returns false and send() returns error.
Implemented in kcenon::network::unified::adapters::quic_connection_adapter, kcenon::network::unified::adapters::tcp_connection_adapter, kcenon::network::unified::adapters::udp_connection_adapter, and kcenon::network::unified::adapters::ws_connection_adapter.
|
nodiscardpure virtual |
Connects to a remote endpoint using host/port.
| endpoint | The remote endpoint to connect to |
Thread-safe. Only one connect operation can succeed at a time.
Implemented in kcenon::network::unified::adapters::quic_connection_adapter, kcenon::network::unified::adapters::tcp_connection_adapter, kcenon::network::unified::adapters::udp_connection_adapter, and kcenon::network::unified::adapters::ws_connection_adapter.
|
nodiscardpure virtual |
Connects to a remote endpoint using URL.
| url | The URL to connect to (e.g., "wss://example.com/ws") |
This overload is primarily for URL-based protocols like WebSocket and HTTP. For socket-based protocols, use the endpoint_info overload.
Same as connect(endpoint_info) plus:
Implemented in kcenon::network::unified::adapters::quic_connection_adapter, kcenon::network::unified::adapters::tcp_connection_adapter, kcenon::network::unified::adapters::udp_connection_adapter, and kcenon::network::unified::adapters::ws_connection_adapter.
|
nodiscardpure virtualnoexcept |
Checks if the connection is in the process of connecting.
Implemented in kcenon::network::unified::adapters::quic_connection_adapter, kcenon::network::unified::adapters::tcp_connection_adapter, kcenon::network::unified::adapters::udp_connection_adapter, and kcenon::network::unified::adapters::ws_connection_adapter.
|
delete |
|
default |
|
pure virtual |
Sets all connection callbacks at once.
| callbacks | The callback structure with handlers |
Replaces all previously set callbacks. Empty callback functions in the structure will clear the corresponding handler.
Thread-safe, but callbacks may be invoked from I/O threads.
Implemented in kcenon::network::unified::adapters::quic_connection_adapter, kcenon::network::unified::adapters::tcp_connection_adapter, kcenon::network::unified::adapters::udp_connection_adapter, and kcenon::network::unified::adapters::ws_connection_adapter.
|
pure virtual |
Sets connection options.
| options | The configuration options |
Some options may only be effective before connect() is called.
Thread-safe. Changes may not affect in-flight operations.
Implemented in kcenon::network::unified::adapters::quic_connection_adapter, kcenon::network::unified::adapters::tcp_connection_adapter, kcenon::network::unified::adapters::udp_connection_adapter, and kcenon::network::unified::adapters::ws_connection_adapter.
|
pure virtual |
Sets the connection timeout.
| timeout | Timeout duration (0 = no timeout) |
Shorthand for setting just the connect_timeout option.
Implemented in kcenon::network::unified::adapters::quic_connection_adapter, kcenon::network::unified::adapters::tcp_connection_adapter, kcenon::network::unified::adapters::udp_connection_adapter, and kcenon::network::unified::adapters::ws_connection_adapter.
|
pure virtual |
Blocks until the component has stopped.
Waits for all pending operations to complete and the connection to be fully closed.
Safe to call from any thread. Uses internal synchronization.
Implemented in kcenon::network::unified::adapters::quic_connection_adapter, kcenon::network::unified::adapters::tcp_connection_adapter, kcenon::network::unified::adapters::udp_connection_adapter, and kcenon::network::unified::adapters::ws_connection_adapter.