Main Page   Modules   Namespace List   Class Hierarchy   Compound List   Namespace Members   Compound Members   Related Pages  

GNE::Address Class Reference
[Mid-Level API]

#include <Address.h>

List of all members.

Public Member Functions

 Address ()
 Constructs an invalid address.

 Address (std::string address)
 Creates a new Address, resolving the name in address if necessary.

 Address (const char *address)
 Alternate version for better implicit conversion.

 Address (NLaddress address)
 Creates a new Address with the HawkNL NLaddress.

void setAddressByName (const std::string &address)
 Does the same work as the constructor.

std::string getNameByAddress () const
 Returns the reverse DNS lookup based on this address.

NLaddress getAddress () const
 Returns a copy of the actual HawkNL address struct.

void setAddress (NLaddress address)
 Sets the address based on the given HawkNL address.

std::string toString () const
 Returns a string representation of this address in the format xxx.xxx.xxx.xxx:ppppp, but if the port is 0, the colon and port number are empty.

int getPort () const
 Returns the port for this address.

void setPort (int port)
 Sets the port for this address.

bool isValid () const
 Returns if this address is in a valid state.

 operator bool () const
 Another method for testing isValid().

bool operator== (const Address &rhs) const
 Tests if two addresses are equal based on the HawkNL function nlCompareAddr.


Detailed Description

A wrapper class for the HawkNL NLaddress. This class is used many times around GNE and is made for ease of use and cleaner code.


Constructor & Destructor Documentation

GNE::Address::Address std::string  address  ) 
 

Creates a new Address, resolving the name in address if necessary.

The format is the same as HawkNL's nlGetAddrFromName, for IP this format is xxx.xxx.xxx.xxx:ppppp where ppppp is the optional port and xxx.xxx.xxx.xxx can be a hostname, i.e.:
localhost:1678
129.21.138.180:5555
www.mozilla.com:80
www.hawksoft.com (when port is empty, resulting port will be 0).

If no string is supplied, the default is 0.0.0.0:0. Note that the name resolution may take some time and this constructor will block. If the resolution failed, then the Address is not valid (!isValid()).

See also:
isValid()


Member Function Documentation

std::string GNE::Address::getNameByAddress  )  const
 

Returns the reverse DNS lookup based on this address.

This method will block. If the name doesn't exist, the IP address will be returned. The port from this address will not be part of the name in either case.

bool GNE::Address::isValid  )  const
 

Returns if this address is in a valid state.

And address will become invalid if a name could not be resolved, or a port sent was out of range.

GNE::Address::operator bool  )  const
 

Another method for testing isValid().

See also:
isValid()

bool GNE::Address::operator== const Address &  rhs  )  const
 

Tests if two addresses are equal based on the HawkNL function nlCompareAddr.

This does not take validity into consideration.

void GNE::Address::setPort int  port  ) 
 

Sets the port for this address.

This is a number 0..65535.


The documentation for this class was generated from the following files:
Generated on Fri Aug 22 13:40:05 2003 for GNE by doxygen1.3