xentara-utils v1.2.1
Xentara utilities library
Loading...
Searching...
No Matches
xentara::utils::network::Address Class Referencefinal

A network address. More...

#include <network/Address.hpp>

Public Types

using size_type = socklen_t
 The type used for native address size.
 

Public Member Functions

constexpr Address () noexcept=default
 Default constructor. Constructs an object for family AF_UNSPEC.
 
template<SockaddrCompatible Sockaddr, tools::OneOf< SocketType, Protocol >... Options>
 Address (const Sockaddr &nativeAddress, Options... options)
 Constructor that copies a native address.
 
template<tools::OneOf< SocketType, Protocol >... Options>
 Address (const sockaddr *data, size_type size, Options... options)
 Constructor that copies a native address with non-standardy size.
 
 operator bool () const noexcept
 Checks whether the object contains a valid address.
 
constexpr auto addressFamily () const noexcept -> int
 Gets the address family of the address.
 
template<tools::OneOf< AddressFamily, SocketType, Protocol >... Criteria>
auto supports (Criteria... criteria) const noexcept -> bool
 Determines whether the address supports a certain set of socket criteria.
 
constexpr auto size () const noexcept -> size_type
 Gets the size of the underlying sockkaddr structure.
 
constexpr auto data () const noexcept -> const sockaddr *
 Returns a pointer to the underlying sockkaddr structure.
 
constexpr auto data () noexcept -> sockaddr *
 Returns a pointer to the underlying sockkaddr structure.
 
auto resize (size_type size) -> void
 Resets the address to a specific size.
 
auto toString () const -> std::string
 Gets the numeric representation of the address as a string.
 

Static Public Member Functions

template<tools::OneOf< WithPort, Protocol, SocketType, AddressFamily >... Options>
static auto loopback (Options... options) -> Address
 Creates a loopback address.
 
template<tools::OneOf< Protocol, SocketType, AddressFamily >... Options>
static auto any (PortNumber portNumber, Options... options) -> Address
 get a local address suitable for binding to all local interfaces
 
template<tools::OneOf< WithPort, RequirePortTag, DefaultPort, Protocol, SocketType, AddressFamily >... Options>
static auto resolve (std::string_view hostName, Options... options) -> std::vector< Address >
 Resolve a host name, returning all suitable addresses.
 
template<tools::OneOf< WithPort, RequirePortTag, DefaultPort, Protocol, SocketType, AddressFamily >... Options>
static auto resolveSingleAddress (std::string_view hostName, Options... options) -> Address
 Resolve a host name, returning the first suitable address.
 
template<tools::OneOf< WithPort, RequirePortTag, DefaultPort, Protocol, SocketType, AddressFamily >... Options>
static auto fromString (std::string_view string, Options... options) -> Address
 Parse a numeric address string.
 
static auto canonicalName (std::string_view hostName) -> std::string
 Get the canonical name for a host.
 
static auto join (std::string_view hostName, PortNumber portNumber) -> std::string
 Joins a host name and a port number.
 
static auto join (std::string_view hostName, std::optional< PortNumber > portNumber) -> std::string
 Joins a host name and a port number, if necessary.
 
static auto split (std::string_view string) -> std::pair< std::string, std::optional< PortNumber > >
 Splits a string into a host name and a port number.
 

Detailed Description

A network address.

Member Typedef Documentation

◆ size_type

The type used for native address size.

Constructor & Destructor Documentation

◆ Address() [1/3]

constexpr xentara::utils::network::Address::Address ( )
constexprdefaultnoexcept

Default constructor. Constructs an object for family AF_UNSPEC.

◆ Address() [2/3]

template<SockaddrCompatible Sockaddr, tools::OneOf< SocketType, Protocol >... Options>
xentara::utils::network::Address::Address ( const Sockaddr &  nativeAddress,
Options...  options 
)

Constructor that copies a native address.

Note

This function allows you to specify a number of options for the address, described under Option Parameters below. Just pass the options in the options parameter pack. To create an address that supports only TCP connections, for example, use the following call:

xentara::utils::network::Address address(nativeAddress, nativeAddressSize, xentara::utils::network::Protocol(IPPROTO_TCP));
A network address.
Definition Address.hpp:66
Protocol
Marker for protocols.
Definition Options.hpp:116
Parameters
nativeAddressA sockkaddr compatible address structure
optionsThe Options to use for the address. See Option Parameters below.
Option Parameters
xentara::utils::network::SocketType(type)Specifies that the address only supports a specific socket type. type can be any of the SOCK_XXX socket type defines, like SOCK_STREAM or SOCK_DGRAM. If you do not specify a socket type, or if you specify 0 for the socket type, then addresses is considered to support any socket type.
xentara::utils::network::Protocol(protocol)Specifies that the address only supports a specific protocol. protocol can be any of the XXXPROTO_YYY protocol defines, like IPPROTO_TCP or IPPROTO_UDP. If you do not specify a protocol, or if you specify 0 for the protocol, then addresses is considered to support any protocol.

◆ Address() [3/3]

template<tools::OneOf< SocketType, Protocol >... Options>
xentara::utils::network::Address::Address ( const sockaddr *  data,
size_type  size,
Options...  options 
)

Constructor that copies a native address with non-standardy size.

Note

This function allows you to specify a number of options for the address, described under Option Parameters below. Just pass the options in the options parameter pack. To create an address that supports only TCP connections, for example, use the following call:

xentara::utils::network::Address address(nativeAddress, nativeAddressSize, xentara::utils::network::Protocol(IPPROTO_TCP));
Parameters
dataA pointer to the sockkaddr structure to copy
sizeA the size of the sockkaddr structure to copy
optionsThe Options to use for the address. See Option Parameters below.
Option Parameters
xentara::utils::network::SocketType(type)Specifies that the address only supports a specific socket type. type can be any of the SOCK_XXX socket type defines, like SOCK_STREAM or SOCK_DGRAM. If you do not specify a socket type, or if you specify 0 for the socket type, then addresses is considered to support any socket type.
xentara::utils::network::Protocol(protocol)Specifies that the address only supports a specific protocol. protocol can be any of the XXXPROTO_YYY protocol defines, like IPPROTO_TCP or IPPROTO_UDP. If you do not specify a protocol, or if you specify 0 for the protocol, then addresses is considered to support any protocol.

Member Function Documentation

◆ addressFamily()

constexpr auto xentara::utils::network::Address::addressFamily ( ) const -> int
constexprnoexcept

Gets the address family of the address.

Returns
The address family. This will be one of the AF_XXX address family defines, like AF_INET or AF_INET6. For default constructed objects, this function returns AF_UNSPEC.

◆ any()

template<tools::OneOf< Protocol, SocketType, AddressFamily >... Options>
static auto xentara::utils::network::Address::any ( PortNumber  portNumber,
Options...  options 
) -> Address
static

get a local address suitable for binding to all local interfaces

This function creates an address that allows binding to any local interface, like INADDR_ANY For IPv4 and in6addr_any for IPv6. You usually do not need to call this function. Use Socket::bind(PortNumber) to bind to any local address.

Note
This function allows you to specify a number of options for the address lookup, described under Option Parameters below. Just pass the options in the options parameter pack. To get a local binding address for TCP port 8080, for example, use the following call:
static auto any(PortNumber portNumber, Options... options) -> Address
get a local address suitable for binding to all local interfaces
Parameters
portNumberThe port number to bind to. Must not be 0.
optionsThe Options to use for the address. See Option Parameters below.
Option Parameters
xentara::utils::network::Protocol(protocol)Specifies that the returned address should support the protocol protocol. protocol can be any of the XXXPROTO_YYY protocol defines, like IPPROTO_TCP or IPPROTO_UDP. If you do not specify this option, or if you specify 0 for the protocol, then an address for any protocol may be returned.
xentara::utils::network::SocketType(socketType)Specifies that the returned address should support the socket type socketType. socketType can be any of the SOCK_XXX socket type defines, like SOCK_STREAM or SOCK_DGRAM. If you do not specify this option, or if you specify 0 for the socket type, then an address for any socket may will be returned.
xentara::utils::network::AddressFamily(addressFamily)Specifies a that the returned address should have the address family addressFamily. addressFamily can be any of the AF_XXX address family defines, like AF_INET or AF_INET6. If you do not specify this option, or if you specify AF_UNSPEC for the address family, then an address of any family may be returned. You should usually not use this option, to allow communication over both IPv4 and IPv6. Only use this option if you are planning to communicate with legacy software that does not support IPv6.
Returns
A local address suited for listening on the given port.
Exceptions
std::runtime_errorAn error occurred
std::invalid_argumentportNumber is 0

◆ canonicalName()

static auto xentara::utils::network::Address::canonicalName ( std::string_view  hostName) -> std::string
static

Get the canonical name for a host.

Parameters
hostNameThe host name. The function also supports numeric address strings.
Returns
The canonical name for the host, or the original hostName, if it could not be found.
Exceptions
std::invalid_argumenthostName is empty

◆ data() [1/2]

constexpr auto xentara::utils::network::Address::data ( ) const -> const sockaddr *
constexprnoexcept

Returns a pointer to the underlying sockkaddr structure.

Returns
The address of the structure

◆ data() [2/2]

constexpr auto xentara::utils::network::Address::data ( ) -> sockaddr *
constexprnoexcept

Returns a pointer to the underlying sockkaddr structure.

Returns
The address of the structure

◆ fromString()

template<tools::OneOf< WithPort, RequirePortTag, DefaultPort, Protocol, SocketType, AddressFamily >... Options>
static auto xentara::utils::network::Address::fromString ( std::string_view  string,
Options...  options 
) -> Address
static

Parse a numeric address string.

Normally, string must be a pure address string, and may not contain a port number, and the returned address will have a port number of 0. You can pass the options xentara::utils::network::WithPort, xentara::utils::network::kRequirePort, or xentara::utils::network::DefaultPort in the options parameter pack to allow or require a port number to be present in string, or to change the port number returned in the address. See Option Parameters below for a description of these options.

Note
This function allows you to specify a number of options for the address lookup, described under Option Parameters below. Just pass the options in the options parameter pack. To create an address for use in a TCP connection with a default port of 8080, for example, use the following call:
static auto fromString(std::string_view string, Options... options) -> Address
Parse a numeric address string.
DefaultPort
Marker for host names/address strings with optional port number.
Definition Options.hpp:60
Parameters
stringThe address string. The function also supports numeric address strings.
optionsThe Options to use for the lookup. See Option Parameters below.
Option Parameters
xentara::utils::network::WithPort(portNumber)Specifies that the returned address should have the port number portNumber instead of port number 0. This option Cannot be combined with xentara::utils::network::kRequirePort or xentara::utils::network::DefaultPort.
xentara::utils::network::kRequirePortSpecifies that string must contain a port number. Cannot be combined with xentara::utils::network::WithPort or xentara::utils::network::DefaultPort.
xentara::utils::network::DefaultPort(portNumber)Specifies that string may contain an optional port number. If string does not contain a port number, portNumber will be used instead. Cannot be combined with xentara::utils::network::WithPort or xentara::utils::network::kRequirePort.
xentara::utils::network::Protocol(protocol)Specifies that the returned addresses should support the protocol protocol. protocol can be any of the XXXPROTO_YYY protocol defines, like IPPROTO_TCP or IPPROTO_UDP. If you do not specify this option, or if you specify 0 for the protocol, then addresses for any protocol will be returned.
xentara::utils::network::SocketType(socketType)Specifies that the returned addresses should support the socket type socketType. socketType can be any of the SOCK_XXX socket type defines, like SOCK_STREAM or SOCK_DGRAM. If you do not specify this option, or if you specify 0 for the socket type, then addresses for any socket type will be returned.
xentara::utils::network::AddressFamily(addressFamily)Specifies a that only addresses with the address family addressFamily should be returned. addressFamily can be any of the AF_XXX address family defines, like AF_INET or AF_INET6. If you do not specify this option, or if you specify AF_UNSPEC for the address family, then addresses of all families will be returned. You should usually not use this option, to allow communication over both IPv4 and IPv6. Only use this option if you are planning to communicate with legacy software that does not support IPv6.
Returns
The first suitable address listed for the host.
Exceptions
BadAddressErrorThe address was not a valid address for the given criteria
std::runtime_errorAn error occurred during the lookup
std::invalid_argumentstring is empty

◆ join() [1/2]

static auto xentara::utils::network::Address::join ( std::string_view  hostName,
PortNumber  portNumber 
) -> std::string
static

Joins a host name and a port number.

If the host name is a numeric IPv6 address, it is wrapped in square brackets, like in URIs. This is necessary because IPv6 addresses contain colons, and so the port number cannot readily be distinguished from the individual parts of the address itself. For example, the IPv6 loopback address with port number 8080 is represented as "[::1]:8080" to avoid confusion with "::1:8080", which is the abbreviated form of the address "0000:0000:0000:0000:0000:0000:0001:8080"

Parameters
hostNameThe host name. The function also supports numeric address strings.
portNumberThe port number
Returns
the joined string

◆ join() [2/2]

static auto xentara::utils::network::Address::join ( std::string_view  hostName,
std::optional< PortNumber portNumber 
) -> std::string
static

Joins a host name and a port number, if necessary.

If a port number is specified, and the host name is a numeric IPv6 address, then the address is wrapped in square brackets, like in URIs. This is necessary because IPv6 addresses contain colons, and so the port number cannot readily be distinguished from the individual parts of the address itself. For example, the IPv6 loopback address with port number 8080 is represented as "[::1]:8080" to distinguish it from "::1:8080", which is the abbreviated form of the address "0000:0000:0000:0000:0000:0000:0001:8080"

Parameters
hostNameThe host name. The function also supports numeric address strings.
portNumberThe port number
Returns
the joined string

◆ loopback()

template<tools::OneOf< WithPort, Protocol, SocketType, AddressFamily >... Options>
static auto xentara::utils::network::Address::loopback ( Options...  options) -> Address
static

Creates a loopback address.

Note
This function allows you to specify a number of options for the address lookup, described under Option Parameters below. Just pass the options in the options parameter pack. To create a loopback TCP address with port number 8080, for example, use the following call:
static auto loopback(Options... options) -> Address
Creates a loopback address.
WithPort
Marker used to specify a fixed port for host names/address strings.
Definition Options.hpp:73
Parameters
optionsThe Options to use for the address. See Option Parameters below.
Option Parameters
xentara::utils::network::WithPort(portNumber)Specifies the port number to use for the returned address. If you do not specify a port number, a port number of 0 will be used.
xentara::utils::network::Protocol(protocol)Specifies that the returned address should support the protocol protocol. protocol can be any of the XXXPROTO_YYY protocol defines, like IPPROTO_TCP or IPPROTO_UDP. If you do not specify this option, or if you specify 0 for the protocol, then an address for any protocol may be returned.
xentara::utils::network::SocketType(socketType)Specifies that the returned address should support the socket type socketType. socketType can be any of the SOCK_XXX socket type defines, like SOCK_STREAM or SOCK_DGRAM. If you do not specify this option, or if you specify 0 for the socket type, then an address for any socket type may be returned.
xentara::utils::network::AddressFamily(addressFamily)Specifies a that the returned address should have the address family addressFamily. addressFamily can be any of the AF_XXX address family defines, like AF_INET or AF_INET6. If you do not specify this option, or if you specify AF_UNSPEC for the address family, then an address of any families may be returned. You should usually not use this option, to allow communication over both IPv4 and IPv6. Only use this option if you are planning to communicate with legacy software that does not support IPv6.
Returns
The loopback address
Exceptions
std::runtime_errorAn error occurred

◆ operator bool()

xentara::utils::network::Address::operator bool ( ) const
explicitnoexcept

Checks whether the object contains a valid address.

Returns
Returns true if the object contains a valid address, or false if the object is default constructed, or otherwise has address family AF_UNSPEC.

◆ resize()

auto xentara::utils::network::Address::resize ( size_type  size) -> void

Resets the address to a specific size.

This function ensures that the buffer returned by data() can hold at least size bytes. You can use this function to resize the internal data before calling a C function that writes an address to a preallocated buffer.

The entire contents of the address is initialized to zero, and the address type is set to AF_UNSPEC.

Parameters
sizeThe new size. Must be al least sizeof(sockaddr::sa_family).

◆ resolve()

template<tools::OneOf< WithPort, RequirePortTag, DefaultPort, Protocol, SocketType, AddressFamily >... Options>
static auto xentara::utils::network::Address::resolve ( std::string_view  hostName,
Options...  options 
) -> std::vector< Address >
static

Resolve a host name, returning all suitable addresses.

Normally, hostName must be a host name or address string, and may not contain a port number, and the returned address will have a port number of 0. You can pass the options xentara::utils::network::WithPort, xentara::utils::network::kRequirePort, or xentara::utils::network::DefaultPort in the options parameter pack to allow or require a port number to be present in hostName, or to change the port number returned in the address. See Option Parameters below for a description of these options.

Depending on the platform, this function may return the same address multiple times if it supports multiple protocols and/or socket types. For each copy of that address, supports() will return true for a different set of criteria. For best results, pass the protocol you wish to use the address for using the xentara::utils::network::Protocol option. If you plan to use the address to establish a TCP/IP connection, for example, pass xentara::utils::network::Protocol(IPPROTO_TCP) as part if the options parameter.

Note
This function allows you to specify a number of options for the address lookup, described under Option Parameters below. Just pass the options in the options parameter pack. To resolve a host name for use in a TCP connection with a default port of 8080, for example, use the following call:
static auto resolve(std::string_view hostName, Options... options) -> std::vector< Address >
Resolve a host name, returning all suitable addresses.
Parameters
hostNameThe host name. The function also supports numeric address strings. Depending on the options passed in the options parameter pack, hostName may also contain a port number.
optionsThe Options to use for the lookup. See Option Parameters below.
Option Parameters
xentara::utils::network::WithPort(portNumber)Specifies that the returned address should have the port number portNumber instead of port number 0. This option Cannot be combined with xentara::utils::network::kRequirePort or xentara::utils::network::DefaultPort.
xentara::utils::network::kRequirePortSpecifies that hostName must contain a port number. Cannot be combined with xentara::utils::network::WithPort or xentara::utils::network::DefaultPort.
xentara::utils::network::DefaultPort(portNumber)Specifies that hostName may contain an optional port number. If hostName does not contain a port number, portNumber will be used instead. Cannot be combined with xentara::utils::network::WithPort or xentara::utils::network::kRequirePort.
xentara::utils::network::Protocol(protocol)Specifies that the returned addresses should support the protocol protocol. protocol can be any of the XXXPROTO_YYY protocol defines, like IPPROTO_TCP or IPPROTO_UDP. If you do not specify this option, or if you specify 0 for the protocol, then addresses for any protocol will be returned.
xentara::utils::network::SocketType(socketType)Specifies that the returned addresses should support the socket type socketType. socketType can be any of the SOCK_XXX socket type defines, like SOCK_STREAM or SOCK_DGRAM. If you do not specify this option, or if you specify 0 for the socket type, then addresses for any socket type will be returned.
xentara::utils::network::AddressFamily(addressFamily)Specifies a that only addresses with the address family addressFamily should be returned. addressFamily can be any of the AF_XXX address family defines, like AF_INET or AF_INET6. If you do not specify this option, or if you specify AF_UNSPEC for the address family, then addresses of all families will be returned. You should usually not use this option, to allow communication over both IPv4 and IPv6. Only use this option if you are planning to communicate with legacy software that does not support IPv6.
Returns
A list of all suitable addresses listed for the host. This list well never be empty.
Exceptions
HostNotFoundErrorThe host name was not found, or the host has no suitable interfaces
std::runtime_errorAn error occurred during the lookup
std::invalid_argumenthostName is empty

◆ resolveSingleAddress()

template<tools::OneOf< WithPort, RequirePortTag, DefaultPort, Protocol, SocketType, AddressFamily >... Options>
static auto xentara::utils::network::Address::resolveSingleAddress ( std::string_view  hostName,
Options...  options 
) -> Address
static

Resolve a host name, returning the first suitable address.

You should not use this function when trying to establish a connection to a remote host. Instead, use resolve(), and try to connect to all returned addresses in turn.

Normally, hostName must be a host name or address string, and may not contain a port number, and the returned address will have a port number of 0. You can pass the options xentara::utils::network::WithPort, xentara::utils::network::kRequirePort, or xentara::utils::network::DefaultPort in the options parameter pack to allow or require a port number to be present in hostName, or to change the port number returned in the address. See Option Parameters below for a description of these options.

Note
This function allows you to specify a number of options for the address lookup, described under Option Parameters below. Just pass the options in the options parameter pack. To resolve a host name for use in a TCP connection with a default port of 8080, for example, use the following call:
static auto resolveSingleAddress(std::string_view hostName, Options... options) -> Address
Resolve a host name, returning the first suitable address.
Parameters
hostNameThe host name. The function also supports numeric address strings. Depending on the options passed in the options parameter pack, hostName may also contain a port number.
optionsThe Options to use for the lookup. See Option Parameters below.
Option Parameters
xentara::utils::network::WithPort(portNumber)Specifies that the returned address should have the port number portNumber instead of port number 0. This option Cannot be combined with xentara::utils::network::kRequirePort or xentara::utils::network::DefaultPort.
xentara::utils::network::kRequirePortSpecifies that hostName must contain a port number. Cannot be combined with xentara::utils::network::WithPort or xentara::utils::network::DefaultPort.
xentara::utils::network::DefaultPort(portNumber)Specifies that hostName may contain an optional port number. If hostName does not contain a port number, portNumber will be used instead. Cannot be combined with xentara::utils::network::WithPort or xentara::utils::network::kRequirePort.
xentara::utils::network::Protocol(protocol)Specifies that the returned addresses should support the protocol protocol. protocol can be any of the XXXPROTO_YYY protocol defines, like IPPROTO_TCP or IPPROTO_UDP. If you do not specify this option, or if you specify 0 for the protocol, then addresses for any protocol will be returned.
xentara::utils::network::SocketType(socketType)Specifies that the returned addresses should support the socket type socketType. socketType can be any of the SOCK_XXX socket type defines, like SOCK_STREAM or SOCK_DGRAM. If you do not specify this option, or if you specify 0 for the socket type, then addresses for any socket type will be returned.
xentara::utils::network::AddressFamily(addressFamily)Specifies a that only addresses with the address family addressFamily should be returned. addressFamily can be any of the AF_XXX address family defines, like AF_INET or AF_INET6. If you do not specify this option, or if you specify AF_UNSPEC for the address family, then addresses of all families will be returned. You should usually not use this option, to allow communication over both IPv4 and IPv6. Only use this option if you are planning to communicate with legacy software that does not support IPv6.
Returns
The first suitable address listed for the host.
Exceptions
HostNotFoundErrorThe host name was not found, or the host has no suitable interfaces
std::runtime_errorAn error occurred during the lookup
std::invalid_argumenthostName is empty

◆ size()

constexpr auto xentara::utils::network::Address::size ( ) const -> size_type
constexprnoexcept

Gets the size of the underlying sockkaddr structure.

Returns the size of the address structure currently stored in this object.

Returns

◆ split()

static auto xentara::utils::network::Address::split ( std::string_view  string) -> std::pair< std::string, std::optional< PortNumber > >
static

Splits a string into a host name and a port number.

This function handles IPv6 addresses wrapped in square brackets, as used in URIs. This allows specifying a port number for IPv6 addresses, even though the addresses themselves contain colons. For example:

  • "::1:8080" is interpreted as an abbreviated form of the IPv6 address "0000:0000:0000:0000:0000:0000:0001:8080"
  • "[::1]:8080" is interpreted as the IPv6 loopback address with port number 8080
    Parameters
    stringThe string to split. Can be empty, in which case an empty string is returned.
    Returns
    A pair containing the host name and the port number. If the string does not contain a port number, or if the string could not be parsed, the original string is returned together with std::nullopt.
    Exceptions
    PortNumberRangeErrorThe string contains a port number that is out of range. Port numbers must be between 1 and 65535.

◆ supports()

template<tools::OneOf< AddressFamily, SocketType, Protocol >... Criteria>
auto xentara::utils::network::Address::supports ( Criteria...  criteria) const -> bool
noexcept

Determines whether the address supports a certain set of socket criteria.

Note
This function expects you to specify the criteria as a special parameters, described under Criterion Parameters below. Just pass the criteria in the criteria parameter pack. To check whether the address supports the TCP protocol, for example, use the following call:
auto supportsTcp = address.supports(xentara::utils::network::Protocol(IPPROTO_TCP));
Parameters
criteriaThe Criteria to check. See Criterion Parameters below.
Criterion Parameters
xentara::utils::network::AddressFamily(addressFamily)Checks whether the address belongs to a the address family addressFamily. addressFamily can be any of the AF_XXX address family defines, like AF_INET or AF_INET6. If you do not specify this criterion, or if you specify AF_UNSPEC for the address family, then the address family is not checked.
xentara::utils::network::SocketType(socketType)Checks whether the address supports the socket type socketType. socketType can be any of the SOCK_XXX socket type defines, like SOCK_STREAM or SOCK_DGRAM. If you do not specify this criterion, or you specify 0 for the socket type, then the supported socket type is not checked.
xentara::utils::network::Protocol(protocol)Checks whether the address supports a specific protocol. protocol can be any of the XXXPROTO_YYY protocol defines, like IPPROTO_TCP or IPPROTO_UDP. If you do not specify this criterion, or if you specify 0 for the protocol, then the supported protocol is not checked.
Returns
Returns true if the address supports all of the given criteria, or false, if one of the options is not supported. If you do not specify any criteria, the function will return true for all valid addresses. For default constructed addresses and other addresses with address family AF_UNSPEC, false is returned.

◆ toString()

auto xentara::utils::network::Address::toString ( ) const -> std::string

Gets the numeric representation of the address as a string.

Member Data Documentation

◆ _ipv4

sockaddr_in xentara::utils::network::Address::_ipv4

◆ _ipv6

sockaddr_in6 xentara::utils::network::Address::_ipv6

◆ _large

sockaddr* xentara::utils::network::Address::_large

◆ _small

sockaddr xentara::utils::network::Address::_small