|
GREM 3.12.0
Game/Rendering Engine Modules for C++
|
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. | |
Combined network address and port number (and potentially other info) that identifies a host, or set of hosts, on the network.
|
inline |
Construct an endpoint from a native sockaddr_storage buffer.
| addrStorage | non-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. |
| length | size of the concrete sockaddr type pointed to by addrStorage, in bytes. Must be positive. |
|
inlinenoexcept |
Implicitly convert or construct a generic endpoint from an IPv4 endpoint.
| endpoint | IPv4 endpoint to construct the endpoint from. |
|
inlinenoexcept |
Implicitly convert or construct a generic endpoint from an IPv6 endpoint.
| endpoint | IPv6 endpoint to construct the endpoint from. |
|
inlineexplicitnoexcept |
Construct an endpoint from an IPv4 address and port number.
| address | IPv4 address of the endpoint to construct. |
| port | port number of the endpoint to construct. |
|
inlineexplicitnoexcept |
Construct an endpoint from an IPv4 address and port number.
| address | IPv4 address of the endpoint to construct. |
| port | port number of the endpoint to construct. |
| scopeID | scope/zone ID of the endpoint to construct. |
|
inlineexplicitnoexcept |
Construct an IPv4 endpoint from a native sockaddr_in structure.
| addr | sockaddr_in structure to construct the endpoint from. |
|
inlineexplicitnoexcept |
Construct an IPv6 endpoint from a native sockaddr_in6 structure.
| addr | sockaddr_in6 structure to construct the endpoint from. |
|
default |
Destructor.
|
inlinenoexcept |
Copy constructor.
|
inlinenoexcept |
Move constructor.
|
inlinestaticnodiscardnoexcept |
Create an endpoint with the ANY address (0.0.0.0 or ::) for a given address family.
| family | address family of the endpoint to create. |
| portNumber | port number of the endpoint to create. |
|
inlinestaticnodiscardnoexcept |
Create an endpoint with the LOOPBACK address (0.0.0.0 or ::) for a given address family.
| family | address family of the endpoint to create. |
| portNumber | port number of the endpoint to create. |
|
staticnodiscardnoexcept |
Parse an endpoint address from an ASCII string representation, and a port number from a decimal ASCII string.
| addressString | string containing the 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 address or port number, or cleared on success. |
|
staticnodiscard |
Parse an endpoint address from an ASCII string representation, and a port number from a decimal ASCII string, throwing an exception on failure.
| addressString | string containing the address representation to parse. |
| portNumberString | string containing the decimal port number to parse. |
| networking::Error | on failure to parse a valid address or port number. |
| std::bad_alloc | on allocation failure. |
|
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.
| family | address family of the address to parse. |
| addressString | string containing the 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 address or port number, or cleared on success. |
|
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.
| family | address family of the address to parse. |
| addressString | string containing the address representation to parse. |
| portNumberString | string containing the decimal port number to parse. |
| networking::Error | on failure to parse a valid address or port number. |
| std::bad_alloc | on allocation failure. |
|
staticnodiscardnoexcept |
Parse an endpoint address from an ASCII string representation with an optional decimal port number.
| string | string 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. |
| errorCode | error code that is filled in on failure to parse a valid address or port number, or cleared on success. |
|
staticnodiscard |
Parse an endpoint address from an ASCII string representation with an optional decimal port number, throwing an exception on failure.
| string | string 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. |
| networking::Error | on failure to parse a valid address or port number. |
|
staticnodiscardnoexcept |
Parse an endpoint address of a specific address family type from an ASCII string representation with an optional decimal port number.
| family | address family of the address to parse. |
| string | string 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. |
| errorCode | error code that is filled in on failure to parse a valid address or port number, or cleared on success. |
|
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.
| family | address family of the address to parse. |
| string | string 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. |
| networking::Error | on failure to parse a valid address or port number. |
|
staticnodiscard |
Resolve the endpoint address and port number of a host through the Domain Name System (DNS) using a getaddrinfo() lookup.
| hostName | null-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. |
| 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. |
|
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.
| hostName | null-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. |
| 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. |
| networking::Error | on failure to resolve the host. |
| std::bad_alloc | on allocation failure. |
|
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.
| family | address family of the endpoint to resolve. |
| hostName | null-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. |
| 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. |
|
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.
| family | address family of the endpoint to resolve. |
| hostName | null-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. |
| 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. |
| networking::Error | on failure to resolve the host. |
| std::bad_alloc | on allocation failure. |
|
staticnodiscard |
Resolve the endpoint address and port number of a host through the Domain Name System (DNS) using a getaddrinfo() lookup.
| host | combined 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". |
| errorCode | error code that is filled in on failure to resolve the host, or cleared on success. |
| 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. |
|
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.
| host | combined 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". |
| 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. |
|
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.
| family | address family of the endpoint to resolve. |
| host | combined 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". |
| errorCode | error code that is filled in on failure to resolve the host, or cleared on success. |
| 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. |
|
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.
| family | address family of the endpoint to resolve. |
| host | combined 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". |
| 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. |
|
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().
| family | address family of the endpoint address to get. |
| errorCode | error code that is filled in on failure to get the local address, or cleared on success. |
|
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.
| family | address family of the endpoint address to get. |
| networking::Error | on failure to get the local address. |
| std::bad_alloc | on allocation failure. |
Copy assignment.
Move assignment.
|
inlinenoexcept |
Set the port number of the endpoint.
| newPortNumber | new port number to set. |
|
inlinenodiscardnoexcept |
Get the address family of the endpoint.
|
inlinenodiscardnoexcept |
Get the size of the endpoint's underlying native address structure.
|
inlinenodiscardnoexcept |
Get the IPv4 endpoint stored by this endpoint.
|
inlinenodiscardnoexcept |
Get the IPv6 endpoint stored by this endpoint.
|
inlinenodiscardnoexcept |
Get the IPv4 address of this endpoint.
|
inlinenodiscardnoexcept |
Get the IPv6 address of this endpoint.
|
inlinenodiscardnoexcept |
Get the port number of the endpoint.
|
inlinenodiscardnoexcept |
Get the scope/zone ID of the endpoint.
|
inlinenodiscardnoexcept |
Check if the value of this endpoint's address is equal to the ANY address (0.0.0.0 or ::).
|
inlinenodiscardnoexcept |
Check if the value of this endpoint's address is a loopback address (127.X.X.X or ::1).
|
inlinenodiscardnoexcept |
Get a pointer to the underlying native address structure of the endpoint.
|
inlinenodiscardnoexcept |
Get a pointer to the underlying native address structure of the endpoint.
|
inlinenodiscardnoexcept |
Compare this endpoint to another for equality.
| other | the endpoint to compare this one to. |
|
inlinenodiscardnoexcept |
Compare this endpoint to another.
| other | the endpoint to compare this one to. |