Deskflow 1.22.0.197
Keyboard and mouse sharing utility
|
Network address type. More...
#include <NetworkAddress.h>
Public Member Functions | |
NetworkAddress ()=default | |
NetworkAddress (int port) | |
NetworkAddress (const std::string &hostname, int port=0) | |
NetworkAddress (const NetworkAddress &) | |
~NetworkAddress () | |
NetworkAddress & | operator= (const NetworkAddress &) |
manipulators | |
size_t | resolve (size_t index=0) |
Resolve address. |
accessors | |
bool | operator== (const NetworkAddress &address) const |
Check address equality. | |
bool | operator!= (const NetworkAddress &address) const |
Check address inequality. | |
bool | isValid () const |
Check address validity. | |
const ArchNetAddress & | getAddress () const |
Get address. | |
int | getPort () const |
Get port. | |
std::string | getHostname () const |
Get hostname. |
Network address type.
This class represents a network address.
|
default |
Constructs the invalid address
|
explicit |
Construct the wildcard address with the given port. port
must not be zero.
NetworkAddress::NetworkAddress | ( | const std::string & | hostname, |
int | port = 0 ) |
Construct the network address for the given hostname
and port
. If hostname
can be parsed as a numerical address then that's how it's used, otherwise it's used as a host name. If hostname
ends in ":[0-9]+" then that suffix is extracted and used as the port, overridding the port parameter. The resulting port must be a valid port number (zero is not a valid port number) otherwise XSocketAddress
is thrown with an error of XSocketAddress::kBadPort
. The hostname is not resolved by the c'tor; use resolve
to do that.
NetworkAddress::NetworkAddress | ( | const NetworkAddress & | addr | ) |
NetworkAddress::~NetworkAddress | ( | ) |
const ArchNetAddress & NetworkAddress::getAddress | ( | ) | const |
Get address.
Returns the address in the platform's native network address structure.
std::string NetworkAddress::getHostname | ( | ) | const |
Get hostname.
Returns the hostname passed to the c'tor sans any port suffix.
int NetworkAddress::getPort | ( | ) | const |
Get port.
Returns the port passed to the c'tor as a suffix to the hostname, if that existed, otherwise as passed directly to the c'tor.
bool NetworkAddress::isValid | ( | ) | const |
Check address validity.
Returns true if this is not the invalid address.
bool NetworkAddress::operator!= | ( | const NetworkAddress & | address | ) | const |
Check address inequality.
Returns true if this address is not equal to address
.
NetworkAddress & NetworkAddress::operator= | ( | const NetworkAddress & | addr | ) |
bool NetworkAddress::operator== | ( | const NetworkAddress & | address | ) | const |
Check address equality.
Returns true if this address is equal to address
.
size_t NetworkAddress::resolve | ( | size_t | index = 0 | ) |
Resolve address.
Resolves the hostname to an address. This can be done any number of times and is done automatically by the c'tor taking a hostname. Throws XSocketAddress if resolution is unsuccessful, after which isValid
returns false until the next call to this method. index - determine index of IP we would like to use from resolved addresses Returns count of successfully resolved addressed.