GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::networking::Endpoint Class Reference

Combined network address and port number (and potentially other info) that identifies a host, or set of hosts, on the network. More...

#include <GREM/networking/Endpoint.hpp>

Public Member Functions

template<typename SockAddr>
requires (same_as<SockAddr, sockaddr_storage> || same_as<SockAddr, sockaddr_in> || same_as<SockAddr, sockaddr_in6> || convertible_to<const SockAddr*, const sockaddr*>)
 Endpoint (const SockAddr *addrStorage, socklen_t length)
 Construct an endpoint from a native sockaddr_storage buffer.
 Endpoint (const IPv4Endpoint &endpoint) noexcept
 Implicitly convert or construct a generic endpoint from an IPv4 endpoint.
 Endpoint (const IPv6Endpoint &endpoint) noexcept
 Implicitly convert or construct a generic endpoint from an IPv6 endpoint.
 Endpoint (const IPv4Address &address, PortNumber port=0) noexcept
 Construct an endpoint from an IPv4 address and port number.
 Endpoint (const IPv6Address &address, PortNumber port=0, ScopeID scopeID=0) noexcept
 Construct an endpoint from an IPv4 address and port number.
 Endpoint (const sockaddr_in &addr) noexcept
 Construct an IPv4 endpoint from a native sockaddr_in structure.
 Endpoint (const sockaddr_in6 &addr) noexcept
 Construct an IPv6 endpoint from a native sockaddr_in6 structure.
 ~Endpoint ()=default
 Destructor.
 Endpoint (const Endpoint &other) noexcept
 Copy constructor.
 Endpoint (Endpoint &&other) noexcept
 Move constructor.
Endpoint & operator= (const Endpoint &other) noexcept
 Copy assignment.
Endpoint & operator= (Endpoint &&other) noexcept
 Move assignment.
void setPortNumber (PortNumber newPortNumber) noexcept
 Set the port number of the endpoint.
AddressFamily getAddressFamily () const noexcept
 Get the address family of the endpoint.
socklen_t getLength () const noexcept
 Get the size of the endpoint's underlying native address structure.
Optional< IPv4Endpoint > getIPv4Endpoint () const noexcept
 Get the IPv4 endpoint stored by this endpoint.
Optional< IPv6Endpoint > getIPv6Endpoint () const noexcept
 Get the IPv6 endpoint stored by this endpoint.
Optional< IPv4Address > getIPv4Address () const noexcept
 Get the IPv4 address of this endpoint.
Optional< IPv6Address > getIPv6Address () const noexcept
 Get the IPv6 address of this endpoint.
PortNumber getPortNumber () const noexcept
 Get the port number of the endpoint.
ScopeID getScopeID () const noexcept
 Get the scope/zone ID of the endpoint.
bool isAddressAny () const noexcept
 Check if the value of this endpoint's address is equal to the ANY address (0.0.0.0 or ::).
bool isAddressLoopback () const noexcept
 Check if the value of this endpoint's address is a loopback address (127.X.X.X or ::1).
sockaddr * get () noexcept
 Get a pointer to the underlying native address structure of the endpoint.
const sockaddr * get () const noexcept
 Get a pointer to the underlying native address structure of the endpoint.
bool operator== (const Endpoint &other) const noexcept
 Compare this endpoint to another for equality.
std::strong_ordering operator<=> (const Endpoint &other) const noexcept
 Compare this endpoint to another.

Static Public Member Functions

static Endpoint any (AddressFamily family, PortNumber portNumber=0) noexcept
 Create an endpoint with the ANY address (0.0.0.0 or ::) for a given address family.
static Endpoint loopback (AddressFamily family, PortNumber portNumber=0) noexcept
 Create an endpoint with the LOOPBACK address (0.0.0.0 or ::) for a given address family.
static Optional< Endpoint > parse (CStringView addressString, CStringView portNumberString, std::error_code &errorCode) noexcept
 Parse an endpoint address from an ASCII string representation, and a port number from a decimal ASCII string.
static Endpoint parse (CStringView addressString, CStringView portNumberString)
 Parse an endpoint address from an ASCII string representation, and a port number from a decimal ASCII string, throwing an exception on failure.
static Optional< Endpoint > parse (AddressFamily family, CStringView addressString, CStringView portNumberString, std::error_code &errorCode) noexcept
 Parse an endpoint address of a specific address family type from an ASCII string representation, and a port number from a decimal ASCII string.
static Endpoint parse (AddressFamily family, CStringView addressString, CStringView portNumberString)
 Parse an endpoint address of a specific address family type from an ASCII string representation, and a port number from a decimal ASCII string, throwing an exception on failure.
static Optional< Endpoint > parse (CStringView string, std::error_code &errorCode) noexcept
 Parse an endpoint address from an ASCII string representation with an optional decimal port number.
static Endpoint parse (CStringView string)
 Parse an endpoint address from an ASCII string representation with an optional decimal port number, throwing an exception on failure.
static Optional< Endpoint > parse (AddressFamily family, CStringView string, std::error_code &errorCode) noexcept
 Parse an endpoint address of a specific address family type from an ASCII string representation with an optional decimal port number.
static Endpoint parse (AddressFamily family, CStringView string)
 Parse an endpoint address of a specific address family type from an ASCII string representation with an optional decimal port number, throwing an exception on failure.
static Optional< Endpoint > resolve (const char *hostName, const char *service, std::error_code &errorCode)
 Resolve the endpoint address and port number of a host through the Domain Name System (DNS) using a getaddrinfo() lookup.
static Endpoint resolve (const char *hostName, const char *service)
 Resolve the endpoint address and port number of a host through the Domain Name System (DNS) using a getaddrinfo() lookup.
static Optional< Endpoint > resolve (AddressFamily family, const char *hostName, const char *service, std::error_code &errorCode)
 Resolve the endpoint address and port number of a host with a specific address family type through the Domain Name System (DNS) using a getaddrinfo() lookup.
static Endpoint resolve (AddressFamily family, const char *hostName, const char *service)
 Resolve the endpoint address and port number of a host with a specific address family type through the Domain Name System (DNS) using a getaddrinfo() lookup.
static Optional< Endpoint > resolve (CStringView host, std::error_code &errorCode)
 Resolve the endpoint address and port number of a host through the Domain Name System (DNS) using a getaddrinfo() lookup.
static Endpoint resolve (CStringView host)
 Resolve the endpoint address and port number of a host through the Domain Name System (DNS) using a getaddrinfo() lookup, throwing an exception on failure.
static Optional< Endpoint > resolve (AddressFamily family, CStringView host, std::error_code &errorCode)
 Resolve the endpoint address and port number of a host with a specific address family type through the Domain Name System (DNS) using a getaddrinfo() lookup.
static Endpoint resolve (AddressFamily family, CStringView host)
 Resolve the endpoint address and port number of a host with a specific address family type through the Domain Name System (DNS) using a getaddrinfo() lookup, throwing an exception on failure.
static Optional< Endpoint > getLocalEndpoint (AddressFamily family, std::error_code &errorCode)
 Get the endpoint address and port of the local host by calling connect() on a temporary connectionless socket to the loopback address on port 9 (the "Discard" service) and querying its local address with getsockname().
static Endpoint getLocalEndpoint (AddressFamily family)
 Get the endpoint address and port of the local host by calling connect() on a temporary connectionless socket to the loopback address on port 9 (the "Discard" service) and querying its local address with getsockname(), throwing an exception on failure.

Detailed Description

Combined network address and port number (and potentially other info) that identifies a host, or set of hosts, on the network.

Constructor & Destructor Documentation

◆ Endpoint() [1/9]

template<typename SockAddr>
requires (same_as<SockAddr, sockaddr_storage> || same_as<SockAddr, sockaddr_in> || same_as<SockAddr, sockaddr_in6> || convertible_to<const SockAddr*, const sockaddr*>)
grem::networking::Endpoint::Endpoint ( const SockAddr * addrStorage,
socklen_t length )
inline

Construct an endpoint from a native sockaddr_storage buffer.

Parameters
addrStoragenon-owning read-only pointer to the address structure or sockaddr_storage to read the endpoint data from. Must point to a valid native address structure of length bytes in size, and must not be nullptr.
lengthsize of the concrete sockaddr type pointed to by addrStorage, in bytes. Must be positive.

◆ Endpoint() [2/9]

grem::networking::Endpoint::Endpoint ( const IPv4Endpoint & endpoint)
inlinenoexcept

Implicitly convert or construct a generic endpoint from an IPv4 endpoint.

Parameters
endpointIPv4 endpoint to construct the endpoint from.

◆ Endpoint() [3/9]

grem::networking::Endpoint::Endpoint ( const IPv6Endpoint & endpoint)
inlinenoexcept

Implicitly convert or construct a generic endpoint from an IPv6 endpoint.

Parameters
endpointIPv6 endpoint to construct the endpoint from.

◆ Endpoint() [4/9]

grem::networking::Endpoint::Endpoint ( const IPv4Address & address,
PortNumber port = 0 )
inlineexplicitnoexcept

Construct an endpoint from an IPv4 address and port number.

Parameters
addressIPv4 address of the endpoint to construct.
portport number of the endpoint to construct.

◆ Endpoint() [5/9]

grem::networking::Endpoint::Endpoint ( const IPv6Address & address,
PortNumber port = 0,
ScopeID scopeID = 0 )
inlineexplicitnoexcept

Construct an endpoint from an IPv4 address and port number.

Parameters
addressIPv4 address of the endpoint to construct.
portport number of the endpoint to construct.
scopeIDscope/zone ID of the endpoint to construct.

◆ Endpoint() [6/9]

grem::networking::Endpoint::Endpoint ( const sockaddr_in & addr)
inlineexplicitnoexcept

Construct an IPv4 endpoint from a native sockaddr_in structure.

Parameters
addrsockaddr_in structure to construct the endpoint from.

◆ Endpoint() [7/9]

grem::networking::Endpoint::Endpoint ( const sockaddr_in6 & addr)
inlineexplicitnoexcept

Construct an IPv6 endpoint from a native sockaddr_in6 structure.

Parameters
addrsockaddr_in6 structure to construct the endpoint from.

◆ ~Endpoint()

grem::networking::Endpoint::~Endpoint ( )
default

Destructor.

◆ Endpoint() [8/9]

grem::networking::Endpoint::Endpoint ( const Endpoint & other)
inlinenoexcept

Copy constructor.

◆ Endpoint() [9/9]

grem::networking::Endpoint::Endpoint ( Endpoint && other)
inlinenoexcept

Move constructor.

Member Function Documentation

◆ any()

Endpoint grem::networking::Endpoint::any ( AddressFamily family,
PortNumber portNumber = 0 )
inlinestaticnodiscardnoexcept

Create an endpoint with the ANY address (0.0.0.0 or ::) for a given address family.

Parameters
familyaddress family of the endpoint to create.
portNumberport number of the endpoint to create.
Returns
Endpoint{XXXXAddress::ANY, portNumber}, where XXXXAddress is the address type corresponding to the specified family.

◆ loopback()

Endpoint grem::networking::Endpoint::loopback ( AddressFamily family,
PortNumber portNumber = 0 )
inlinestaticnodiscardnoexcept

Create an endpoint with the LOOPBACK address (0.0.0.0 or ::) for a given address family.

Parameters
familyaddress family of the endpoint to create.
portNumberport number of the endpoint to create.
Returns
Endpoint{XXXXAddress::LOOPBACK, portNumber}, where XXXXAddress is the address type corresponding to the specified family.

◆ parse() [1/8]

Optional< Endpoint > grem::networking::Endpoint::parse ( CStringView addressString,
CStringView portNumberString,
std::error_code & errorCode )
staticnodiscardnoexcept

Parse an endpoint address from an ASCII string representation, and a port number from a decimal ASCII string.

Parameters
addressStringstring containing the address representation to parse.
portNumberStringstring containing the decimal port number to parse.
errorCodeerror code that is filled in on failure to parse a valid address or port number, or cleared on success.
Returns
the parsed endpoint, or an empty optional if parsing failed.

◆ parse() [2/8]

Endpoint grem::networking::Endpoint::parse ( CStringView addressString,
CStringView portNumberString )
staticnodiscard

Parse an endpoint address from an ASCII string representation, and a port number from a decimal ASCII string, throwing an exception on failure.

Parameters
addressStringstring containing the address representation to parse.
portNumberStringstring containing the decimal port number to parse.
Returns
the parsed endpoint.
Exceptions
networking::Erroron failure to parse a valid address or port number.
std::bad_allocon allocation failure.

◆ parse() [3/8]

Optional< Endpoint > grem::networking::Endpoint::parse ( AddressFamily family,
CStringView addressString,
CStringView portNumberString,
std::error_code & errorCode )
staticnodiscardnoexcept

Parse an endpoint address of a specific address family type from an ASCII string representation, and a port number from a decimal ASCII string.

Parameters
familyaddress family of the address to parse.
addressStringstring containing the address representation to parse.
portNumberStringstring containing the decimal port number to parse.
errorCodeerror code that is filled in on failure to parse a valid address or port number, or cleared on success.
Returns
the parsed endpoint, or an empty optional if parsing failed.

◆ parse() [4/8]

Endpoint grem::networking::Endpoint::parse ( AddressFamily family,
CStringView addressString,
CStringView portNumberString )
staticnodiscard

Parse an endpoint address of a specific address family type from an ASCII string representation, and a port number from a decimal ASCII string, throwing an exception on failure.

Parameters
familyaddress family of the address to parse.
addressStringstring containing the address representation to parse.
portNumberStringstring containing the decimal port number to parse.
Returns
the parsed endpoint.
Exceptions
networking::Erroron failure to parse a valid address or port number.
std::bad_allocon allocation failure.

◆ parse() [5/8]

Optional< Endpoint > grem::networking::Endpoint::parse ( CStringView string,
std::error_code & errorCode )
staticnodiscardnoexcept

Parse an endpoint address from an ASCII string representation with an optional decimal port number.

Parameters
stringstring containing the address representation to parse, and potentially a decimal port number separated by a colon if the address is enclosed in square brackets or does not contain another colon.
errorCodeerror code that is filled in on failure to parse a valid address or port number, or cleared on success.
Returns
the parsed endpoint, or an empty optional if parsing failed.

◆ parse() [6/8]

Endpoint grem::networking::Endpoint::parse ( CStringView string)
staticnodiscard

Parse an endpoint address from an ASCII string representation with an optional decimal port number, throwing an exception on failure.

Parameters
stringstring containing the address representation to parse, and potentially a decimal port number separated by a colon if the address is enclosed in square brackets or does not contain another colon.
Returns
the parsed endpoint.
Exceptions
networking::Erroron failure to parse a valid address or port number.

◆ parse() [7/8]

Optional< Endpoint > grem::networking::Endpoint::parse ( AddressFamily family,
CStringView string,
std::error_code & errorCode )
staticnodiscardnoexcept

Parse an endpoint address of a specific address family type from an ASCII string representation with an optional decimal port number.

Parameters
familyaddress family of the address to parse.
stringstring containing the address representation to parse, and potentially a decimal port number separated by a colon if the address is enclosed in square brackets or does not contain another colon.
errorCodeerror code that is filled in on failure to parse a valid address or port number, or cleared on success.
Returns
the parsed endpoint, or an empty optional if parsing failed.

◆ parse() [8/8]

Endpoint grem::networking::Endpoint::parse ( AddressFamily family,
CStringView string )
staticnodiscard

Parse an endpoint address of a specific address family type from an ASCII string representation with an optional decimal port number, throwing an exception on failure.

Parameters
familyaddress family of the address to parse.
stringstring containing the address representation to parse, and potentially a decimal port number separated by a colon if the address is enclosed in square brackets or does not contain another colon.
Returns
the parsed endpoint.
Exceptions
networking::Erroron failure to parse a valid address or port number.

◆ resolve() [1/8]

Optional< Endpoint > grem::networking::Endpoint::resolve ( const char * hostName,
const char * service,
std::error_code & errorCode )
staticnodiscard

Resolve the endpoint address and port number of a host through the Domain Name System (DNS) using a getaddrinfo() lookup.

Parameters
hostNamenull-terminated domain name or address string of the host to look up, e.g. "example.com", "127.0.0.1" or "::1", or nullptr to look up by service only. Must not be nullptr if service is nullptr.
servicenull-terminated service or port string of the host to look up, e.g. "http" or "80", or nullptr to look up by host name only. Must not be nullptr if hostName is nullptr.
errorCodeerror code that is filled in on failure to resolve the host, or cleared on success.
Returns
the resolved endpoint, or an empty optional if resolution failed.

◆ resolve() [2/8]

Endpoint grem::networking::Endpoint::resolve ( const char * hostName,
const char * service )
staticnodiscard

Resolve the endpoint address and port number of a host through the Domain Name System (DNS) using a getaddrinfo() lookup.

throwing an exception on failure.

Parameters
hostNamenull-terminated domain name or address string of the host to look up, e.g. "example.com", "127.0.0.1" or "::1", or nullptr to look up by service only. Must not be nullptr if service is nullptr.
servicenull-terminated service or port string of the host to look up, e.g. "http" or "80", or nullptr to look up by host name only. Must not be nullptr if hostName is nullptr.
Returns
the resolved endpoint.
Exceptions
networking::Erroron failure to resolve the host.
std::bad_allocon allocation failure.

◆ resolve() [3/8]

Optional< Endpoint > grem::networking::Endpoint::resolve ( AddressFamily family,
const char * hostName,
const char * service,
std::error_code & errorCode )
staticnodiscard

Resolve the endpoint address and port number of a host with a specific address family type through the Domain Name System (DNS) using a getaddrinfo() lookup.

Parameters
familyaddress family of the endpoint to resolve.
hostNamenull-terminated domain name or address string of the host to look up, e.g. "example.com", "127.0.0.1" or "::1", or nullptr to look up by service only. Must not be nullptr if service is nullptr.
servicenull-terminated service or port string of the host to look up, e.g. "http" or "80", or nullptr to look up by host name only. Must not be nullptr if hostName is nullptr.
errorCodeerror code that is filled in on failure to resolve the host, or cleared on success.
Returns
the resolved endpoint, or an empty optional if resolution failed.

◆ resolve() [4/8]

Endpoint grem::networking::Endpoint::resolve ( AddressFamily family,
const char * hostName,
const char * service )
staticnodiscard

Resolve the endpoint address and port number of a host with a specific address family type through the Domain Name System (DNS) using a getaddrinfo() lookup.

throwing an exception on failure.

Parameters
familyaddress family of the endpoint to resolve.
hostNamenull-terminated domain name or address string of the host to look up, e.g. "example.com", "127.0.0.1" or "::1", or nullptr to look up by service only. Must not be nullptr if service is nullptr.
servicenull-terminated service or port string of the host to look up, e.g. "http" or "80", or nullptr to look up by host name only. Must not be nullptr if hostName is nullptr.
Returns
the resolved endpoint.
Exceptions
networking::Erroron failure to resolve the host.
std::bad_allocon allocation failure.

◆ resolve() [5/8]

Optional< Endpoint > grem::networking::Endpoint::resolve ( CStringView host,
std::error_code & errorCode )
staticnodiscard

Resolve the endpoint address and port number of a host through the Domain Name System (DNS) using a getaddrinfo() lookup.

Parameters
hostcombined host name and service string separated by a colon, e.g. "example.com:http", "127.0.0.1:80" or "[::1]:80", or a host name-only string, e.g. "example.com", "127.0.0.1" or "::1".
errorCodeerror code that is filled in on failure to resolve the host, or cleared on success.
Returns
the resolved endpoint, or an empty optional if resolution failed.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ resolve() [6/8]

Endpoint grem::networking::Endpoint::resolve ( CStringView host)
staticnodiscard

Resolve the endpoint address and port number of a host through the Domain Name System (DNS) using a getaddrinfo() lookup, throwing an exception on failure.

Parameters
hostcombined host name and service string separated by a colon, e.g. "example.com:http", "127.0.0.1:80" or "[::1]:80", or a host name-only string, e.g. "example.com", "127.0.0.1" or "::1".
Returns
the resolved endpoint.
Exceptions
networking::Erroron failure to resolve the host.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ resolve() [7/8]

Optional< Endpoint > grem::networking::Endpoint::resolve ( AddressFamily family,
CStringView host,
std::error_code & errorCode )
staticnodiscard

Resolve the endpoint address and port number of a host with a specific address family type through the Domain Name System (DNS) using a getaddrinfo() lookup.

Parameters
familyaddress family of the endpoint to resolve.
hostcombined host name and service string separated by a colon, e.g. "example.com:http", "127.0.0.1:80" or "[::1]:80", or a host name-only string, e.g. "example.com", "127.0.0.1" or "::1".
errorCodeerror code that is filled in on failure to resolve the host, or cleared on success.
Returns
the resolved endpoint, or an empty optional if resolution failed.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ resolve() [8/8]

Endpoint grem::networking::Endpoint::resolve ( AddressFamily family,
CStringView host )
staticnodiscard

Resolve the endpoint address and port number of a host with a specific address family type through the Domain Name System (DNS) using a getaddrinfo() lookup, throwing an exception on failure.

Parameters
familyaddress family of the endpoint to resolve.
hostcombined host name and service string separated by a colon, e.g. "example.com:http", "127.0.0.1:80" or "[::1]:80", or a host name-only string, e.g. "example.com", "127.0.0.1" or "::1".
Returns
the resolved endpoint.
Exceptions
networking::Erroron failure to resolve the host.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ getLocalEndpoint() [1/2]

Optional< Endpoint > grem::networking::Endpoint::getLocalEndpoint ( AddressFamily family,
std::error_code & errorCode )
staticnodiscard

Get the endpoint address and port of the local host by calling connect() on a temporary connectionless socket to the loopback address on port 9 (the "Discard" service) and querying its local address with getsockname().

Parameters
familyaddress family of the endpoint address to get.
errorCodeerror code that is filled in on failure to get the local address, or cleared on success.
Returns
the local endpoint, or an empty optional on failure.

◆ getLocalEndpoint() [2/2]

Endpoint grem::networking::Endpoint::getLocalEndpoint ( AddressFamily family)
staticnodiscard

Get the endpoint address and port of the local host by calling connect() on a temporary connectionless socket to the loopback address on port 9 (the "Discard" service) and querying its local address with getsockname(), throwing an exception on failure.

Parameters
familyaddress family of the endpoint address to get.
Returns
the local endpoint.
Exceptions
networking::Erroron failure to get the local address.
std::bad_allocon allocation failure.

◆ operator=() [1/2]

Endpoint & grem::networking::Endpoint::operator= ( const Endpoint & other)
inlinenoexcept

Copy assignment.

◆ operator=() [2/2]

Endpoint & grem::networking::Endpoint::operator= ( Endpoint && other)
inlinenoexcept

Move assignment.

◆ setPortNumber()

void grem::networking::Endpoint::setPortNumber ( PortNumber newPortNumber)
inlinenoexcept

Set the port number of the endpoint.

Parameters
newPortNumbernew port number to set.

◆ getAddressFamily()

AddressFamily grem::networking::Endpoint::getAddressFamily ( ) const
inlinenodiscardnoexcept

Get the address family of the endpoint.

Returns
the endpoint's address family.

◆ getLength()

socklen_t grem::networking::Endpoint::getLength ( ) const
inlinenodiscardnoexcept

Get the size of the endpoint's underlying native address structure.

Returns
the endpoint's length, in bytes.

◆ getIPv4Endpoint()

Optional< IPv4Endpoint > grem::networking::Endpoint::getIPv4Endpoint ( ) const
inlinenodiscardnoexcept

Get the IPv4 endpoint stored by this endpoint.

Returns
the IPv4 endpoint if the address family is IPv4, or an empty optional otherwise.

◆ getIPv6Endpoint()

Optional< IPv6Endpoint > grem::networking::Endpoint::getIPv6Endpoint ( ) const
inlinenodiscardnoexcept

Get the IPv6 endpoint stored by this endpoint.

Returns
the IPv6 endpoint if the address family is IPv6, or an empty optional otherwise.

◆ getIPv4Address()

Optional< IPv4Address > grem::networking::Endpoint::getIPv4Address ( ) const
inlinenodiscardnoexcept

Get the IPv4 address of this endpoint.

Returns
the endpoint's IPv4 if its address family is IPv4, or an empty optional otherwise.

◆ getIPv6Address()

Optional< IPv6Address > grem::networking::Endpoint::getIPv6Address ( ) const
inlinenodiscardnoexcept

Get the IPv6 address of this endpoint.

Returns
the endpoint's IPv6 if its address family is IPv6, or an empty optional otherwise.

◆ getPortNumber()

PortNumber grem::networking::Endpoint::getPortNumber ( ) const
inlinenodiscardnoexcept

Get the port number of the endpoint.

Returns
the endpoint's port number, or 0 if it does not have a port number.

◆ getScopeID()

ScopeID grem::networking::Endpoint::getScopeID ( ) const
inlinenodiscardnoexcept

Get the scope/zone ID of the endpoint.

Returns
the endpoint's scope/zone ID, or 0 if it does not have a scope/zone ID.

◆ isAddressAny()

bool grem::networking::Endpoint::isAddressAny ( ) const
inlinenodiscardnoexcept

Check if the value of this endpoint's address is equal to the ANY address (0.0.0.0 or ::).

Returns
true if this endpoint has the ANY address, false otherwise.

◆ isAddressLoopback()

bool grem::networking::Endpoint::isAddressLoopback ( ) const
inlinenodiscardnoexcept

Check if the value of this endpoint's address is a loopback address (127.X.X.X or ::1).

Returns
true if this endpoint has a loopback address, false otherwise.

◆ get() [1/2]

sockaddr * grem::networking::Endpoint::get ( )
inlinenodiscardnoexcept

Get a pointer to the underlying native address structure of the endpoint.

Returns
a non-owning pointer to the underlying address structure.

◆ get() [2/2]

const sockaddr * grem::networking::Endpoint::get ( ) const
inlinenodiscardnoexcept

Get a pointer to the underlying native address structure of the endpoint.

Returns
a non-owning read-only pointer to the underlying address structure.

◆ operator==()

bool grem::networking::Endpoint::operator== ( const Endpoint & other) const
inlinenodiscardnoexcept

Compare this endpoint to another for equality.

Parameters
otherthe endpoint to compare this one to.
Returns
true if the endpoints are equal, false otherwise.

◆ operator<=>()

std::strong_ordering grem::networking::Endpoint::operator<=> ( const Endpoint & other) const
inlinenodiscardnoexcept

Compare this endpoint to another.

Parameters
otherthe endpoint to compare this one to.
Returns
a strong ordering between the two endpoints.

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