Deskflow 1.22.0.197
Keyboard and mouse sharing utility
Loading...
Searching...
No Matches
NetworkAddress Class Reference

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 ()
NetworkAddressoperator= (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 ArchNetAddressgetAddress () const
 Get address.
int getPort () const
 Get port.
std::string getHostname () const
 Get hostname.

Detailed Description

Network address type.

This class represents a network address.

Constructor & Destructor Documentation

◆ NetworkAddress() [1/4]

NetworkAddress::NetworkAddress ( )
default

Constructs the invalid address

◆ NetworkAddress() [2/4]

NetworkAddress::NetworkAddress ( int port)
explicit

Construct the wildcard address with the given port. port must not be zero.

◆ NetworkAddress() [3/4]

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() [4/4]

NetworkAddress::NetworkAddress ( const NetworkAddress & addr)

◆ ~NetworkAddress()

NetworkAddress::~NetworkAddress ( )

Member Function Documentation

◆ getAddress()

const ArchNetAddress & NetworkAddress::getAddress ( ) const

Get address.

Returns the address in the platform's native network address structure.

◆ getHostname()

std::string NetworkAddress::getHostname ( ) const

Get hostname.

Returns the hostname passed to the c'tor sans any port suffix.

◆ getPort()

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.

◆ isValid()

bool NetworkAddress::isValid ( ) const

Check address validity.

Returns true if this is not the invalid address.

◆ operator!=()

bool NetworkAddress::operator!= ( const NetworkAddress & address) const

Check address inequality.

Returns true if this address is not equal to address.

◆ operator=()

NetworkAddress & NetworkAddress::operator= ( const NetworkAddress & addr)

◆ operator==()

bool NetworkAddress::operator== ( const NetworkAddress & address) const

Check address equality.

Returns true if this address is equal to address.

◆ resolve()

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.


The documentation for this class was generated from the following files: