Combined IPv6Address, PortNumber and ScopeID.
More...
#include <GREM/networking/Endpoint.hpp>
|
| constexpr | IPv6Endpoint (const IPv6Address &address, PortNumber port=0, ScopeID scopeID=0) noexcept |
| | Construct an IPv6 endpoint from an IPv6 address, port number and scope/zone ID.
|
| constexpr | IPv6Endpoint (const sockaddr_in6 &addr) noexcept |
| | Construct an IPv6 endpoint from a native sockaddr_in6 structure.
|
| constexpr void | setAddress (const IPv6Address &newAddress) noexcept |
| | Set the address of the endpoint.
|
| constexpr void | setPortNumber (PortNumber newPortNumber) noexcept |
| | Set the port number of the endpoint.
|
| constexpr void | setScopeID (ScopeID newScopeID) noexcept |
| | Set the scope/zone ID of the endpoint.
|
| constexpr IPv6Address | getAddress () const noexcept |
| | Get the address of the endpoint.
|
| constexpr PortNumber | getPortNumber () const noexcept |
| | Get the port number of the endpoint.
|
| constexpr ScopeID | getScopeID () const noexcept |
| | Get the scope/zone ID of the endpoint.
|
| constexpr bool | isAddressAny () const noexcept |
| | Check if the value of this endpoint's IPv6 address is equal to the ANY address (::).
|
| constexpr bool | isAddressLoopback () const noexcept |
| | Check if the value of this endpoint's IPv6 address is equal to the LOOPBACK address (::1).
|
| constexpr sockaddr_in6 * | get () noexcept |
| | Get a pointer to the underlying native sockaddr_in6 structure of the IPv6 endpoint.
|
| constexpr const sockaddr_in6 * | get () const noexcept |
| | Get a pointer to the underlying native sockaddr_in6 structure of the IPv6 endpoint.
|
| constexpr bool | operator== (const IPv6Endpoint &other) const noexcept |
| | Compare this endpoint to another for equality.
|
| constexpr std::strong_ordering | operator<=> (const IPv6Endpoint &other) const noexcept |
| | Compare this endpoint to another.
|
|
| static Optional< IPv6Endpoint > | parse (CStringView addressString, CStringView portNumberString, std::error_code &errorCode) noexcept |
| | Parse an IPv6 address from an ASCII string representation, and a port number from a decimal ASCII string.
|
| static IPv6Endpoint | parse (CStringView addressString, CStringView portNumberString) |
| | Parse an IPv6 address from an ASCII string representation, and a port number from a decimal ASCII string, throwing an exception on failure.
|
| static Optional< IPv6Endpoint > | parse (CStringView string, std::error_code &errorCode) noexcept |
| | Parse an IPv6 address from an ASCII string representation with an optional decimal port number.
|
| static IPv6Endpoint | parse (CStringView string) |
| | Parse an IPv6 address from an ASCII string representation with an optional decimal port number, throwing an exception on failure.
|
| static Optional< IPv6Endpoint > | resolve (const char *hostName, const char *service, std::error_code &errorCode) |
| | Resolve the IPv6 address and port number of a host through the Domain Name System (DNS) using a getaddrinfo() lookup.
|
| static IPv6Endpoint | resolve (const char *hostName, const char *service) |
| | Resolve the IPv6 address and port number of a host through the Domain Name System (DNS) using a getaddrinfo() lookup, throwing an exception on failure.
|
| static Optional< IPv6Endpoint > | resolve (CStringView host, std::error_code &errorCode) |
| | Resolve the IPv6 address and port number of a host through the Domain Name System (DNS) using a getaddrinfo() lookup.
|
| static IPv6Endpoint | resolve (CStringView host) |
| | Resolve the IPv6 address and port number of a host through the Domain Name System (DNS) using a getaddrinfo() lookup, throwing an exception on failure.
|
| static Optional< IPv6Endpoint > | getLocalEndpoint (std::error_code &errorCode) |
| | Get the IPv6 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 IPv6Endpoint | getLocalEndpoint () |
| | Get the IPv6 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.
|
◆ IPv6Endpoint() [1/2]
|
|
inlineexplicitconstexprnoexcept |
Construct an IPv6 endpoint from an IPv6 address, port number and scope/zone ID.
- Parameters
-
| address | IPv6 address of the endpoint. |
| port | port number of the endpoint. |
| scopeID | scope/zone ID of the endpoint. |
◆ IPv6Endpoint() [2/2]
| grem::networking::IPv6Endpoint::IPv6Endpoint |
( |
const sockaddr_in6 & | addr | ) |
|
|
inlineexplicitconstexprnoexcept |
Construct an IPv6 endpoint from a native sockaddr_in6 structure.
- Parameters
-
| addr | sockaddr_in6 structure to construct the IPv6 endpoint from. |
◆ parse() [1/4]
Parse an IPv6 address from an ASCII string representation, and a port number from a decimal ASCII string.
- Parameters
-
| addressString | string containing the IPv6 address representation to parse. |
| portNumberString | string containing the decimal port number to parse. |
| errorCode | error code that is filled in on failure to parse a valid IPv6 address or port number, or cleared on success. |
- Returns
- the parsed IPv6 endpoint, or an empty optional if parsing failed.
◆ parse() [2/4]
Parse an IPv6 address from an ASCII string representation, and a port number from a decimal ASCII string, throwing an exception on failure.
- Parameters
-
| addressString | string containing the IPv6 address representation to parse. |
| portNumberString | string containing the decimal port number to parse. |
- Returns
- the parsed IPv6 endpoint.
- Exceptions
-
| networking::Error | on failure to parse a valid IPv6 address or port number. |
| std::bad_alloc | on allocation failure. |
◆ parse() [3/4]
Parse an IPv6 address from an ASCII string representation with an optional decimal port number.
- Parameters
-
| string | string containing the IPv6 address representation to parse, and potentially a decimal port number separated by a colon if the address is enclosed in square brackets. |
| errorCode | error code that is filled in on failure to parse a valid IPv6 address or port number, or cleared on success. |
- Returns
- the parsed IPv6 endpoint, or an empty optional if parsing failed.
◆ parse() [4/4]
Parse an IPv6 address from an ASCII string representation with an optional decimal port number, throwing an exception on failure.
- Parameters
-
| string | string containing the IPv6 address representation to parse, and potentially a decimal port number separated by a colon if the address is enclosed in square brackets. |
- Returns
- the parsed IPv6 endpoint.
- Exceptions
-
| networking::Error | on failure to parse a valid IPv6 address or port number. |
| std::bad_alloc | on allocation failure. |
◆ resolve() [1/4]
| Optional< IPv6Endpoint > grem::networking::IPv6Endpoint::resolve |
( |
const char * | hostName, |
|
|
const char * | service, |
|
|
std::error_code & | errorCode ) |
|
staticnodiscard |
Resolve the IPv6 address and port number of a host through the Domain Name System (DNS) using a getaddrinfo() lookup.
- Parameters
-
| hostName | null-terminated domain name or address string of the host to look up, e.g. "example.com" or "::1", or nullptr to look up by service only. Must not be nullptr if service is nullptr. |
| service | null-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. |
| errorCode | error code that is filled in on failure to resolve the host, or cleared on success. |
- Returns
- the resolved IPv6 endpoint, or an empty optional if resolution failed.
◆ resolve() [2/4]
| IPv6Endpoint grem::networking::IPv6Endpoint::resolve |
( |
const char * | hostName, |
|
|
const char * | service ) |
|
staticnodiscard |
Resolve the IPv6 address and port number of a host through the Domain Name System (DNS) using a getaddrinfo() lookup, throwing an exception on failure.
- Parameters
-
| hostName | null-terminated domain name or address string of the host to look up, e.g. "example.com" or "::1", or nullptr to look up by service only. Must not be nullptr if service is nullptr. |
| service | null-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 IPv6 endpoint.
- Exceptions
-
| networking::Error | on failure to resolve the host. |
| std::bad_alloc | on allocation failure. |
◆ resolve() [3/4]
Resolve the IPv6 address and port number of a host through the Domain Name System (DNS) using a getaddrinfo() lookup.
- Parameters
-
| host | combined host name and service string separated by a colon, e.g. "example.com:http" or "[::1]:80", or a host name-only string, e.g. "example.com" or "::1". |
| errorCode | error code that is filled in on failure to resolve the host, or cleared on success. |
- Returns
- the resolved IPv6 endpoint, or an empty optional if resolution failed.
- Exceptions
-
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
◆ resolve() [4/4]
Resolve the IPv6 address and port number of a host through the Domain Name System (DNS) using a getaddrinfo() lookup, throwing an exception on failure.
- Parameters
-
| host | combined host name and service string separated by a colon, e.g. "example.com:http" or "[::1]:80", or a host name-only string, e.g. "example.com" or "::1". |
- Returns
- the resolved IPv6 endpoint.
- Exceptions
-
| networking::Error | on failure to resolve the host. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
◆ getLocalEndpoint() [1/2]
| Optional< IPv6Endpoint > grem::networking::IPv6Endpoint::getLocalEndpoint |
( |
std::error_code & | errorCode | ) |
|
|
staticnodiscard |
Get the IPv6 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
-
| errorCode | error code that is filled in on failure to get the local address, or cleared on success. |
- Returns
- the local IPv6 endpoint, or an empty optional on failure.
◆ getLocalEndpoint() [2/2]
| IPv6Endpoint grem::networking::IPv6Endpoint::getLocalEndpoint |
( |
| ) |
|
|
staticnodiscard |
Get the IPv6 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.
- Returns
- the local IPv6 endpoint.
- Exceptions
-
| networking::Error | on failure to get the local address. |
| std::bad_alloc | on allocation failure. |
◆ setAddress()
| void grem::networking::IPv6Endpoint::setAddress |
( |
const IPv6Address & | newAddress | ) |
|
|
inlineconstexprnoexcept |
Set the address of the endpoint.
- Parameters
-
| newAddress | new address to set. |
◆ setPortNumber()
| void grem::networking::IPv6Endpoint::setPortNumber |
( |
PortNumber | newPortNumber | ) |
|
|
inlineconstexprnoexcept |
Set the port number of the endpoint.
- Parameters
-
| newPortNumber | new port number to set. |
◆ setScopeID()
| void grem::networking::IPv6Endpoint::setScopeID |
( |
ScopeID | newScopeID | ) |
|
|
inlineconstexprnoexcept |
Set the scope/zone ID of the endpoint.
- Parameters
-
| newScopeID | new scope/zone ID to set. |
◆ getAddress()
| IPv6Address grem::networking::IPv6Endpoint::getAddress |
( |
| ) |
const |
|
inlinenodiscardconstexprnoexcept |
Get the address of the endpoint.
- Returns
- the endpoint's address.
◆ getPortNumber()
| PortNumber grem::networking::IPv6Endpoint::getPortNumber |
( |
| ) |
const |
|
inlinenodiscardconstexprnoexcept |
Get the port number of the endpoint.
- Returns
- the endpoint's port number.
◆ getScopeID()
| ScopeID grem::networking::IPv6Endpoint::getScopeID |
( |
| ) |
const |
|
inlinenodiscardconstexprnoexcept |
Get the scope/zone ID of the endpoint.
- Returns
- the endpoint's scope/zone ID.
◆ isAddressAny()
| bool grem::networking::IPv6Endpoint::isAddressAny |
( |
| ) |
const |
|
inlinenodiscardconstexprnoexcept |
Check if the value of this endpoint's IPv6 address is equal to the ANY address (::).
- Returns
- getAddress().isAny().
◆ isAddressLoopback()
| bool grem::networking::IPv6Endpoint::isAddressLoopback |
( |
| ) |
const |
|
inlinenodiscardconstexprnoexcept |
Check if the value of this endpoint's IPv6 address is equal to the LOOPBACK address (::1).
- Returns
- getAddress().isLoopback().
◆ get() [1/2]
| sockaddr_in6 * grem::networking::IPv6Endpoint::get |
( |
| ) |
|
|
inlinenodiscardconstexprnoexcept |
Get a pointer to the underlying native sockaddr_in6 structure of the IPv6 endpoint.
- Returns
- a non-owning pointer to the underlying sockaddr_in6 structure.
◆ get() [2/2]
| const sockaddr_in6 * grem::networking::IPv6Endpoint::get |
( |
| ) |
const |
|
inlinenodiscardconstexprnoexcept |
Get a pointer to the underlying native sockaddr_in6 structure of the IPv6 endpoint.
- Returns
- a non-owning read-only pointer to the underlying sockaddr_in6 structure.
◆ operator==()
| bool grem::networking::IPv6Endpoint::operator== |
( |
const IPv6Endpoint & | other | ) |
const |
|
inlinenodiscardconstexprnoexcept |
Compare this endpoint to another for equality.
- Parameters
-
| other | the endpoint to compare this one to. |
- Returns
- true if the addresses, ports and scope/zone IDs are equal, false otherwise.
◆ operator<=>()
| std::strong_ordering grem::networking::IPv6Endpoint::operator<=> |
( |
const IPv6Endpoint & | other | ) |
const |
|
inlinenodiscardconstexprnoexcept |
Compare this endpoint to another.
- Parameters
-
| other | the endpoint to compare this one to. |
- Returns
- a strong ordering between the two endpoints, based on the lexicographical ordering of their addresses' big-endian byte value arrays, or their port numbers if the addresses are equal, or their scope/zone IDs if the port numbers are also equal.
The documentation for this class was generated from the following file: