CNetworkAddress Class Reference

Network address type. More...

#include <CNetworkAddress.h>

Collaboration diagram for CNetworkAddress:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 CNetworkAddress ()
 CNetworkAddress (int port)
 CNetworkAddress (const CString &hostname, int port)
 CNetworkAddress (const CNetworkAddress &)
CNetworkAddress & operator= (const CNetworkAddress &)
manipulators



void resolve ()
 Resolve address.
accessors



bool operator== (const CNetworkAddress &address) const
 Check address equality.
bool operator!= (const CNetworkAddress &address) const
 Check address inequality.
bool isValid () const
 Check address validity.
const CArchNetAddress & getAddress () const
 Get address.
int getPort () const
 Get port.
CString getHostname () const
 Get hostname.

Detailed Description

Network address type.

This class represents a network address.

Definition at line 26 of file CNetworkAddress.h.


Constructor & Destructor Documentation

CNetworkAddress::CNetworkAddress (  ) 

Constructs the invalid address

Definition at line 27 of file CNetworkAddress.cpp.

CNetworkAddress::CNetworkAddress ( int  port  ) 

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

Definition at line 36 of file CNetworkAddress.cpp.

CNetworkAddress::CNetworkAddress ( const CString &  hostname,
int  port 
)

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.

Definition at line 54 of file CNetworkAddress.cpp.

References XSocketAddress::kBadPort.


Member Function Documentation

const CArchNetAddress & CNetworkAddress::getAddress (  )  const

Get address.

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

Definition at line 184 of file CNetworkAddress.cpp.

Referenced by CTCPSocket::bind(), CTCPListenSocket::bind(), CTCPSocket::connect(), and CClient::connect().

CString CNetworkAddress::getHostname (  )  const

Get hostname.

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

Definition at line 196 of file CNetworkAddress.cpp.

Referenced by CClient::connect(), and CClientTaskBarReceiver::updateStatus().

int CNetworkAddress::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.

Definition at line 190 of file CNetworkAddress.cpp.

Referenced by CClient::connect().

bool CNetworkAddress::isValid (  )  const

Check address validity.

Returns true if this is not the invalid address.

Definition at line 178 of file CNetworkAddress.cpp.

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

Check address inequality.

Returns true if this address is not equal to address.

Definition at line 172 of file CNetworkAddress.cpp.

References operator==().

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

Check address equality.

Returns true if this address is equal to address.

Definition at line 166 of file CNetworkAddress.cpp.

Referenced by operator!=().

void CNetworkAddress::resolve (  ) 

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.

Definition at line 130 of file CNetworkAddress.cpp.

References XSocketAddress::kNoAddress, XSocketAddress::kNotFound, XSocketAddress::kUnknown, and XSocketAddress::kUnsupported.

Referenced by CClient::connect().


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

Generated on 12 Nov 2010 for synergy-plus by  doxygen 1.6.1