CoreComponents 3.0.0
A Modern C++ Toolkit
|
Socket address More...
#include <cc/SocketAddress>
Public Member Functions | |
SocketAddress ()=default | |
Create a null socket address. | |
SocketAddress (New) | |
Create a new socket address. | |
SocketAddress (const String &address, int port=0) | |
Create a socket address. | |
SocketAddress (ProtocolFamily family, const String &address="", int port=0) | |
Create a socket address. | |
SocketAddress (int port) | |
Create an IPv4 broadcast address. | |
SocketAddress (const Socket &socket) | |
Retrieve locally bound socket address of socket. | |
ProtocolFamily | family () const |
Protocol family | |
SocketType | socketType () const |
Socket type if this address is a result of name resolution | |
InternetProtocol | protocol () const |
Socket protocol if this address is a result of name resolution | |
int | port () const |
Service port | |
void | setPort (int port) |
Change the service port | |
String | networkAddress () const |
Convert the socket address to a string (sans port number) | |
String | toString () const |
Convert the full address to a string (with port number) | |
int | scope () const |
IPv6 scope of this address. | |
void | setScope (int scope) |
Change the IPv6 scope. | |
String | lookupHostName () const |
Lookup the host name of this address. | |
String | lookupServiceName () const |
Lookup the service name of this address. | |
uint64_t | networkPrefix () const |
Returns network prefix (the leading 64 bits of an IPv6 address). | |
int | bitLength () const |
Size of the address in bits | |
struct sockaddr * | addr () |
Provide access to the underlying low-level address structure. | |
const struct sockaddr * | addr () const |
Provide access to the underlying low-level address structure (read-only) | |
int | addrLen () const |
Size of the underlying low-level address structure in bytes | |
int | level () const |
Level parameter used to set socket options | |
bool | operator== (const SocketAddress &other) const |
Equal to operator. | |
std::strong_ordering | operator<=> (const SocketAddress &other) const |
Ordering operator. | |
Public Member Functions inherited from Object | |
Object ()=default | |
Create a null object. | |
operator bool () const | |
Check if this is a non-null object. | |
bool | isNull () const |
Check if this is a null object. | |
template<class T > | |
bool | is () const |
Check if this object is of type T. | |
template<class T > | |
T | as () const |
Cast this object to type T. | |
bool | isWeak () const |
Check if the underlying object reference is weak. | |
bool | operator== (const Object &other) const |
Equality operator. | |
std::strong_ordering | operator<=> (const Object &other) const |
Ordering operator. | |
long | useCount () const |
Reference count. | |
Static Public Member Functions | |
static SocketAddress | resolveHostName (const String &hostName, int port=0) |
Resolve Internet address of a host. | |
static SocketAddress | resolveHostAndServiceName (const String &hostName, const String &serviceName) |
Resolve Internet address of a host. | |
static List< SocketAddress > | queryConnectionInfo (const String &hostName, const String &serviceName="", ProtocolFamily family=ProtocolFamily::Unspec, SocketType socketType=SocketType::Unspec, Out< String > canonicalName=None{}) |
Query the complete connection information for given host name, service name and protocol family. | |
Additional Inherited Members | |
Protected Member Functions inherited from Object | |
template<class T > | |
T | weak () const |
template<class T > | |
void | initOnce () |
Create the object state when called the first time. | |
template<class T > | |
void | initOncePerThread () |
Create a distinct object state for each thread when called the first time in that thread. | |
Object (State *newState) | |
Initialize object with newState. | |
Object (State *state, Alias) | |
Object (State *state, Weak) | |
Object & | operator= (std::nullptr_t) |
Static Protected Member Functions inherited from Object | |
template<class T > | |
static T | alias (const State *state) |
Create an alias object for the given state. | |
template<class T > | |
static T | weak (const State *state) |
Protected Attributes inherited from Object | |
Handle< State > | me |
Internal object state | |
Socket address
|
default |
Create a null socket address.
|
explicit |
Create a new socket address.
|
explicit |
Create a socket address.
address | Numerical host address, wildcard ("*", "::") or file path |
port | Service port |
InvalidAddressSyntax |
|
explicit |
Create a socket address.
family | Protocol family |
address | Numerical host address, wildcard ("*", "::") or file path |
port | Service port |
InvalidAddressSyntax |
|
explicit |
Create an IPv4 broadcast address.
|
explicit |
Retrieve locally bound socket address of socket.
|
static |
Resolve Internet address of a host.
hostName | Host or domain name to resolve |
port | Port number to set |
HostNameResolutionError |
|
static |
Resolve Internet address of a host.
hostName | Host or domain name to resolve |
serviceName | Service name to resolve (e.g. "http") |
HostNameResolutionError |
|
static |
Query the complete connection information for given host name, service name and protocol family.
The call blocks until the local resolver has resolved the host name. This may take several seconds. Depending on supported protocol stacks and service availability in different protocols (UDP/TCP) and number of network addresses of the queried host multiple SocketAddress objects will be returned. An empty list is returned, if the host name is unknown, service is not available or protocol family is not supported by the host. The host name can be a short name relative to the local domain. The fully qualified domain name (aka canonical name) can be optionally retrieved.
hostName | Host or domain name to resolve |
serviceName | Service name (e.g. "http") |
family | Protocol family |
socketType | Socket type. |
canonicalName | Optionally return the fully qualified domain name |
HostNameResolutionError |
ProtocolFamily family | ( | ) | const |
Protocol family
SocketType socketType | ( | ) | const |
Socket type if this address is a result of name resolution
InternetProtocol protocol | ( | ) | const |
Socket protocol if this address is a result of name resolution
int port | ( | ) | const |
Service port
void setPort | ( | int | port | ) |
Change the service port
String networkAddress | ( | ) | const |
Convert the socket address to a string (sans port number)
String toString | ( | ) | const |
Convert the full address to a string (with port number)
int scope | ( | ) | const |
IPv6 scope of this address.
void setScope | ( | int | scope | ) |
Change the IPv6 scope.
String lookupHostName | ( | ) | const |
Lookup the host name of this address.
Usually a reverse DNS lookup will be issued, which may take several seconds.
HostNameLookupError |
String lookupServiceName | ( | ) | const |
Lookup the service name of this address.
In most setups the service name will be looked up in a local file (/etc/services) and therefore the call returns almost immediately.
ServiceNameLookupError |
uint64_t networkPrefix | ( | ) | const |
Returns network prefix (the leading 64 bits of an IPv6 address).
For an IPv4 address the entire address is returned.
int bitLength | ( | ) | const |
Size of the address in bits
struct sockaddr * addr | ( | ) |
Provide access to the underlying low-level address structure.
const struct sockaddr * addr | ( | ) | const |
Provide access to the underlying low-level address structure (read-only)
int addrLen | ( | ) | const |
Size of the underlying low-level address structure in bytes
int level | ( | ) | const |
Level parameter used to set socket options
bool operator== | ( | const SocketAddress & | other | ) | const |
Equal to operator.
std::strong_ordering operator<=> | ( | const SocketAddress & | other | ) | const |
Ordering operator.