|
Network System 0.1.1
High-performance modular networking library for scalable client-server applications
|
Example showing the new unified client interface usage. More...
#include <kcenon/network/protocol/protocol.h>#include <kcenon/network/unified/unified.h>#include <cstddef>#include <iostream>#include <span>#include <vector>
Go to the source code of this file.
Functions | |
| void | handle_connection (std::unique_ptr< unified::i_connection > conn) |
| Protocol-agnostic connection handler. | |
| void | tcp_example () |
| TCP client example using unified API. | |
| void | udp_example () |
| UDP client example using unified API. | |
| void | websocket_example () |
| WebSocket client example using unified API. | |
| std::unique_ptr< unified::i_connection > | create_connection (const std::string &protocol, const unified::endpoint_info &endpoint) |
| Example of protocol selection at runtime. | |
| int | main () |
Example showing the new unified client interface usage.
This file demonstrates the NEW, RECOMMENDED way of creating network clients using the unified interface API.
Benefits:
Definition in file unified_client_example.cpp.
| std::unique_ptr< unified::i_connection > create_connection | ( | const std::string & | protocol, |
| const unified::endpoint_info & | endpoint ) |
Example of protocol selection at runtime.
Definition at line 113 of file unified_client_example.cpp.
References kcenon::network::protocol::tcp::connect(), kcenon::network::protocol::udp::connect(), kcenon::network::protocol::websocket::connect(), kcenon::network::unified::endpoint_info::host, and kcenon::network::unified::endpoint_info::port.

| void handle_connection | ( | std::unique_ptr< unified::i_connection > | conn | ) |
Protocol-agnostic connection handler.
This function works with ANY protocol - TCP, UDP, WebSocket, QUIC. The unified interface enables truly protocol-agnostic code.
Definition at line 40 of file unified_client_example.cpp.
Referenced by tcp_example(), udp_example(), and websocket_example().

| int main | ( | ) |
Definition at line 131 of file unified_client_example.cpp.
| void tcp_example | ( | ) |
TCP client example using unified API.
Definition at line 78 of file unified_client_example.cpp.
References kcenon::network::protocol::tcp::connect(), and handle_connection().

| void udp_example | ( | ) |
UDP client example using unified API.
Definition at line 89 of file unified_client_example.cpp.
References kcenon::network::protocol::udp::connect(), and handle_connection().

| void websocket_example | ( | ) |
WebSocket client example using unified API.
Definition at line 100 of file unified_client_example.cpp.
References kcenon::network::protocol::websocket::connect(), and handle_connection().
