|
Common System 0.2.0
Common interfaces and patterns for system integration
|
Abstract interface for UDP client implementations. More...
#include <udp_client_interface.h>


Public Member Functions | |
| virtual | ~IUdpClient ()=default |
| virtual::kcenon::common::VoidResult | connect (const std::string &host, uint16_t port)=0 |
| Connect to a remote endpoint for optimized sending. | |
| virtual::kcenon::common::VoidResult | connect (const udp_endpoint &endpoint) |
| Connect to a remote endpoint. | |
| virtual::kcenon::common::VoidResult | send (std::span< const uint8_t > data)=0 |
| Send data to the connected endpoint. | |
| virtual::kcenon::common::VoidResult | send (std::span< const uint8_t > data, const udp_send_options &options) |
| Send data to the connected endpoint with options. | |
| virtual::kcenon::common::VoidResult | send_to (std::span< const uint8_t > data, const udp_endpoint &endpoint)=0 |
| Send data to a specific endpoint (connectionless) | |
| virtual bool | is_connected () const =0 |
| Check if the client is connected to an endpoint. | |
| virtual std::optional< udp_endpoint > | get_remote_endpoint () const |
| Get the currently connected endpoint. | |
| virtual void | disconnect ()=0 |
| Disconnect from the current endpoint. | |
| virtual udp_statistics | get_statistics () const |
| Get send statistics. | |
| virtual void | reset_statistics () |
| Reset statistics. | |
| virtual std::string | get_implementation_name () const |
| Get the implementation name for logging/debugging. | |
| ::kcenon::common::VoidResult | send (const std::string &data) |
| Send string data to the connected endpoint. | |
| ::kcenon::common::VoidResult | send_to (const std::string &data, const udp_endpoint &endpoint) |
| Send string data to a specific endpoint. | |
Abstract interface for UDP client implementations.
This interface defines the contract for UDP client implementations, allowing modules to send UDP datagrams without direct dependencies on specific networking libraries (e.g., ASIO, socket API, etc.).
Example usage:
Definition at line 136 of file udp_client_interface.h.
|
virtualdefault |
|
pure virtual |
Connect to a remote endpoint for optimized sending.
This establishes a "connected" UDP socket, which allows the kernel to cache routing information and perform error checking.
| host | Remote hostname or IP address |
| port | Remote port number |
Implemented in kcenon::common::interfaces::null_udp_client.
Referenced by connect().

|
inline |
Connect to a remote endpoint.
| endpoint | Remote endpoint |
Definition at line 157 of file udp_client_interface.h.
References connect(), kcenon::common::interfaces::udp_endpoint::host, and kcenon::common::interfaces::udp_endpoint::port.

|
pure virtual |
Disconnect from the current endpoint.
After disconnecting, send() will fail until connect() is called again. send_to() can still be used for connectionless sends.
Implemented in kcenon::common::interfaces::null_udp_client.
|
inlinenodiscardvirtual |
Get the implementation name for logging/debugging.
Implemented in kcenon::common::interfaces::null_udp_client.
Definition at line 236 of file udp_client_interface.h.
|
inlinenodiscardvirtual |
Get the currently connected endpoint.
Definition at line 207 of file udp_client_interface.h.
|
inlinenodiscardvirtual |
Get send statistics.
Definition at line 223 of file udp_client_interface.h.
|
nodiscardpure virtual |
Check if the client is connected to an endpoint.
Implemented in kcenon::common::interfaces::null_udp_client.
|
inlinevirtual |
|
inline |
Send string data to the connected endpoint.
| data | String to send |
Definition at line 247 of file udp_client_interface.h.
References send().

|
pure virtual |
Send data to the connected endpoint.
Requires a prior successful call to connect().
| data | Data to send |
Implemented in kcenon::common::interfaces::null_udp_client.
Referenced by send(), and send().

|
inline |
Send data to the connected endpoint with options.
| data | Data to send |
| options | Send options |
Definition at line 178 of file udp_client_interface.h.
References send().

|
inline |
Send string data to a specific endpoint.
| data | String to send |
| endpoint | Target endpoint |
Definition at line 259 of file udp_client_interface.h.
References send_to().

|
pure virtual |
Send data to a specific endpoint (connectionless)
Sends data without requiring a prior connect() call.
| data | Data to send |
| endpoint | Target endpoint |
Implemented in kcenon::common::interfaces::null_udp_client.
Referenced by send_to().
