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

Network endpoint information (host/port or URL) More...

#include <types.h>

Collaboration diagram for kcenon::network::unified::endpoint_info:
Collaboration graph

Public Member Functions

 endpoint_info ()=default
 Default constructor creates an empty endpoint.
 
 endpoint_info (const std::string &h, uint16_t p)
 Constructs endpoint from host and port.
 
 endpoint_info (const char *h, uint16_t p)
 Constructs endpoint from C-string host and port.
 
 endpoint_info (const std::string &url)
 Constructs endpoint from URL (port extracted if present)
 
 endpoint_info (const char *url)
 Constructs endpoint from C-string URL.
 
auto is_valid () const noexcept -> bool
 Checks if the endpoint is valid (non-empty host)
 
auto to_string () const -> std::string
 Returns string representation of the endpoint.
 
auto operator== (const endpoint_info &other) const noexcept -> bool
 Equality comparison.
 
auto operator!= (const endpoint_info &other) const noexcept -> bool
 Inequality comparison.
 

Public Attributes

std::string host
 Hostname, IP address, or full URL.
 
uint16_t port = 0
 Port number (0 if embedded in URL)
 

Detailed Description

Network endpoint information (host/port or URL)

Represents a network endpoint that can be either a host:port combination or a full URL (for protocols like WebSocket that use URLs).

Thread Safety

Immutable after construction, safe for concurrent read access.

Examples

// Host/port style
endpoint_info tcp_ep{"192.168.1.1", 8080};
endpoint_info local_ep{"localhost", 3000};
// URL style (for WebSocket, HTTP)
endpoint_info ws_ep{"wss://example.com/ws"};
// Copy and compare
auto ep2 = tcp_ep;
if (tcp_ep == ep2) { ... }
Network endpoint information (host/port or URL)
Definition types.h:56
endpoint_info()=default
Default constructor creates an empty endpoint.
Examples
unified_messaging_example.cpp.

Definition at line 56 of file types.h.

Constructor & Destructor Documentation

◆ endpoint_info() [1/5]

kcenon::network::unified::endpoint_info::endpoint_info ( )
default

Default constructor creates an empty endpoint.

◆ endpoint_info() [2/5]

kcenon::network::unified::endpoint_info::endpoint_info ( const std::string & h,
uint16_t p )
inline

Constructs endpoint from host and port.

Parameters
hHostname or IP address
pPort number

Definition at line 70 of file types.h.

70: host(h), port(p) {}
std::string host
Hostname, IP address, or full URL.
Definition types.h:57
uint16_t port
Port number (0 if embedded in URL)
Definition types.h:58

◆ endpoint_info() [3/5]

kcenon::network::unified::endpoint_info::endpoint_info ( const char * h,
uint16_t p )
inline

Constructs endpoint from C-string host and port.

Parameters
hHostname or IP address (C-string)
pPort number

Definition at line 77 of file types.h.

77: host(h), port(p) {}

◆ endpoint_info() [4/5]

kcenon::network::unified::endpoint_info::endpoint_info ( const std::string & url)
inlineexplicit

Constructs endpoint from URL (port extracted if present)

Parameters
urlFull URL (e.g., "wss://example.com:443/ws")

For URL-based protocols, the host field contains the full URL and port may be 0 if embedded in the URL.

Definition at line 86 of file types.h.

86: host(url), port(0) {}

◆ endpoint_info() [5/5]

kcenon::network::unified::endpoint_info::endpoint_info ( const char * url)
inlineexplicit

Constructs endpoint from C-string URL.

Parameters
urlFull URL (C-string)

Definition at line 92 of file types.h.

92: host(url), port(0) {}

Member Function Documentation

◆ is_valid()

auto kcenon::network::unified::endpoint_info::is_valid ( ) const -> bool
inlinenodiscardnoexcept

Checks if the endpoint is valid (non-empty host)

Returns
true if host is not empty

Definition at line 98 of file types.h.

98{ return !host.empty(); }

References host.

◆ operator!=()

auto kcenon::network::unified::endpoint_info::operator!= ( const endpoint_info & other) const -> bool
inlinenodiscardnoexcept

Inequality comparison.

Definition at line 121 of file types.h.

121 {
122 return !(*this == other);
123 }

◆ operator==()

auto kcenon::network::unified::endpoint_info::operator== ( const endpoint_info & other) const -> bool
inlinenodiscardnoexcept

Equality comparison.

Definition at line 114 of file types.h.

114 {
115 return host == other.host && port == other.port;
116 }

References host, and port.

◆ to_string()

auto kcenon::network::unified::endpoint_info::to_string ( ) const -> std::string
inlinenodiscard

Returns string representation of the endpoint.

Returns
"host:port" or URL string

Definition at line 104 of file types.h.

104 {
105 if (port == 0) {
106 return host;
107 }
108 return host + ":" + std::to_string(port);
109 }

References host, and port.

Member Data Documentation

◆ host

std::string kcenon::network::unified::endpoint_info::host

Hostname, IP address, or full URL.

Examples
unified_messaging_example.cpp.

Definition at line 57 of file types.h.

Referenced by is_valid(), main(), operator==(), and to_string().

◆ port

uint16_t kcenon::network::unified::endpoint_info::port = 0

Port number (0 if embedded in URL)

Examples
unified_messaging_example.cpp.

Definition at line 58 of file types.h.

Referenced by main(), operator==(), and to_string().


The documentation for this struct was generated from the following file: