NHostAddress Class Reference

NHostAddress class abstracts an ip address/hostname. More...

Inheritance diagram for NHostAddress:

NObject NObject

List of all members.

Public Member Functions

 NHostAddress (void)
 Constructs a NHostAddress object.
 NHostAddress (const NString &addr)
 Constructs a NHostAddress object.
 NHostAddress (const NHostAddress &addr)
 Constructs a NHostAddress object.
 NHostAddress (const sockaddr *addr)
 Constructs a NHostAddress object.
void clear (void)
 Resets the host address hold by the object.
void setAddress (nuint32 ip)
 Sets the host address hold by the object to a given ip address.
void setAddress (const NString &addr)
 Sets the host address hold by the object to a given host address.
void setAddress (const sockaddr *sock)
 Sets the host address hold by the object to a given address.
nuint32 resolve (void) const
 Resolves the address of the host.
NString toString (void) const
 Returns the resolved address in a NString format.
NString address (void) const
 Returns the host address as originally set.
NList< NStringaliases (void)
 Returns a list with all the aliases of the host.
NList< nuint32addresses (void)
 Returns a list with all the ip addresses of the host.
bool isNull (void) const
 Tests whether the host is NULL (0.0.0.0).
bool isLocalhost (void) const
 Tests wheter the host is localhost (127.0.0.1).
NHostAddressoperator= (const NHostAddress &rhs)
 Assigns a NHostAddress to the object.
NHostAddressoperator= (const NString &rhs)
 Assigns an address to the object.
 NHostAddress (void)
 Constructs a NHostAddress object.
 NHostAddress (const NString &addr)
 Constructs a NHostAddress object.
 NHostAddress (const NHostAddress &addr)
 Constructs a NHostAddress object.
 NHostAddress (const sockaddr *addr)
 Constructs a NHostAddress object.
void clear (void)
 Resets the host address hold by the object.
void setAddress (nuint32 ip)
 Sets the host address hold by the object to a given ip address.
void setAddress (const NString &addr)
 Sets the host address hold by the object to a given host address.
void setAddress (const sockaddr *sock)
 Sets the host address hold by the object to a given address.
nuint32 resolve (void) const
 Resolves the address of the host.
NString toString (void) const
 Returns the resolved address in a NString format.
NString address (void) const
 Returns the host address as originally set.
NList< NStringaliases (void)
 Returns a list with all the aliases of the host.
NList< nuint32addresses (void)
 Returns a list with all the ip addresses of the host.
bool isNull (void) const
 Tests whether the host is NULL (0.0.0.0).
bool isLocalhost (void) const
 Tests wheter the host is localhost (127.0.0.1).
NHostAddressoperator= (const NHostAddress &rhs)
 Assigns a NHostAddress to the object.
NHostAddressoperator= (const NString &rhs)
 Assigns an address to the object.

Static Public Member Functions

static NString toString (nuint32 ip)
 Returns a given ip addresss in a NString format.
static NString toString (nuint32 ip)
 Returns a given ip addresss in a NString format.


Detailed Description

NHostAddress class abstracts an ip address/hostname.

Definition at line 48 of file linux/nhostaddress.h.


Constructor & Destructor Documentation

NHostAddress ( const NString addr  ) 

Constructs a NHostAddress object.

Parameters:
addr The address (ip or hostname)

Definition at line 34 of file linux/nhostaddress.cpp.

NHostAddress ( const NHostAddress addr  ) 

Constructs a NHostAddress object.

Parameters:
addr The object to be copied
Note:
Copy constructor

Definition at line 43 of file linux/nhostaddress.cpp.

References m_addr, and m_host.

NHostAddress ( const sockaddr *  addr  ) 

Constructs a NHostAddress object.

Parameters:
addr A pointer to a sockaddr structure

Definition at line 52 of file linux/nhostaddress.cpp.

References setAddress().

NHostAddress ( const NString addr  ) 

Constructs a NHostAddress object.

Parameters:
addr The address (ip or hostname)

NHostAddress ( const NHostAddress addr  ) 

Constructs a NHostAddress object.

Parameters:
addr The object to be copied
Note:
Copy constructor

NHostAddress ( const sockaddr *  addr  ) 

Constructs a NHostAddress object.

Parameters:
addr A pointer to a sockaddr structure


Member Function Documentation

void setAddress ( nuint32  ip  ) 

Sets the host address hold by the object to a given ip address.

Parameters:
ip The ip address of the host in network byte order

Definition at line 66 of file linux/nhostaddress.cpp.

References NString::number().

Referenced by NHostAddress(), and NTcpSocket::peerAddress().

void setAddress ( const NString addr  ) 

Sets the host address hold by the object to a given host address.

Parameters:
addr The host address

Definition at line 71 of file linux/nhostaddress.cpp.

void setAddress ( const sockaddr *  sock  ) 

Sets the host address hold by the object to a given address.

Parameters:
sock A pointer to a sockaddr structure containing the host address

Definition at line 75 of file linux/nhostaddress.cpp.

nuint32 resolve ( void   )  const

Resolves the address of the host.

Returns:
Returns the 32bit unsigned integer representing the host address
Note:
The returned integer will be in network byte order
Exceptions:
NMemException If runs out of memory
NResolveException If get a low level error
NHostTryAgainException If requested to try again
NHostNotFoundException If the host was not found

Definition at line 82 of file linux/nhostaddress.cpp.

References NException::NETWORK, and NString::toChar().

Referenced by NTcpSocket::connectToHost(), NMySql::connectToHost(), and toString().

NString toString ( void   )  const

Returns the resolved address in a NString format.

Returns:
A NString object with the ip address of the host

Definition at line 135 of file linux/nhostaddress.cpp.

References resolve().

Referenced by NTcpSocket::connectToHost(), NMySql::connectToHost(), NTcpSocket::execListen(), NMySql::getError(), NAbstractSocket::NAbstractSocket(), NTcpSocket::peerName(), NTcpSocket::read(), NTcpSocket::readLine(), and NTcpSocket::waitForConnected().

NString toString ( nuint32  ip  )  [static]

Returns a given ip addresss in a NString format.

Parameters:
ip The ip address in network byte order
Returns:
A NString object with the ip address of the host

Definition at line 151 of file linux/nhostaddress.cpp.

References NException::NETWORK, and NString::number().

NString address ( void   )  const

Returns the host address as originally set.

Returns:
The host address

Definition at line 166 of file linux/nhostaddress.cpp.

NList< NString > aliases ( void   ) 

Returns a list with all the aliases of the host.

Returns:
A NList<NString> object with the aliases of the host

Definition at line 171 of file linux/nhostaddress.cpp.

References NList::append().

NList< nuint32 > addresses ( void   ) 

Returns a list with all the ip addresses of the host.

Returns:
A NList<nuint32> object with all the ip addresses of the host
Note:
The ip addresses will be in network byte order

Definition at line 186 of file linux/nhostaddress.cpp.

References NList::append().

bool isNull ( void   )  const

Tests whether the host is NULL (0.0.0.0).

Returns:
true if it is null or false otherwise

Definition at line 207 of file linux/nhostaddress.cpp.

bool isLocalhost ( void   )  const

Tests wheter the host is localhost (127.0.0.1).

Returns:
true if it is localhost of false otherwise

Definition at line 216 of file linux/nhostaddress.cpp.

NHostAddress & operator= ( const NHostAddress rhs  ) 

Assigns a NHostAddress to the object.

Parameters:
rhs The NHostAddress being copied
Returns:
A reference to the object

Definition at line 225 of file linux/nhostaddress.cpp.

References m_addr.

NHostAddress & operator= ( const NString rhs  ) 

Assigns an address to the object.

Parameters:
rhs The address of the host
Returns:
A reference to the object

Definition at line 232 of file linux/nhostaddress.cpp.

void setAddress ( nuint32  ip  ) 

Sets the host address hold by the object to a given ip address.

Parameters:
ip The ip address of the host in network byte order

void setAddress ( const NString addr  ) 

Sets the host address hold by the object to a given host address.

Parameters:
addr The host address

void setAddress ( const sockaddr *  sock  ) 

Sets the host address hold by the object to a given address.

Parameters:
sock A pointer to a sockaddr structure containing the host address

nuint32 resolve ( void   )  const

Resolves the address of the host.

Returns:
Returns the 32bit unsigned integer representing the host address
Note:
The returned integer will be in network byte order
Exceptions:
NMemException If runs out of memory
NResolveException If get a low level error
NHostTryAgainException If requested to try again
NHostNotFoundException If the host was not found

NString toString ( void   )  const

Returns the resolved address in a NString format.

Returns:
A NString object with the ip address of the host

static NString toString ( nuint32  ip  )  [static]

Returns a given ip addresss in a NString format.

Parameters:
ip The ip address in network byte order
Returns:
A NString object with the ip address of the host

NString address ( void   )  const

Returns the host address as originally set.

Returns:
The host address

NList<NString> aliases ( void   ) 

Returns a list with all the aliases of the host.

Returns:
A NList<NString> object with the aliases of the host

NList<nuint32> addresses ( void   ) 

Returns a list with all the ip addresses of the host.

Returns:
A NList<nuint32> object with all the ip addresses of the host
Note:
The ip addresses will be in network byte order

bool isNull ( void   )  const

Tests whether the host is NULL (0.0.0.0).

Returns:
true if it is null or false otherwise

bool isLocalhost ( void   )  const

Tests wheter the host is localhost (127.0.0.1).

Returns:
true if it is localhost of false otherwise

NHostAddress& operator= ( const NHostAddress rhs  ) 

Assigns a NHostAddress to the object.

Parameters:
rhs The NHostAddress being copied
Returns:
A reference to the object

NHostAddress& operator= ( const NString rhs  ) 

Assigns an address to the object.

Parameters:
rhs The address of the host
Returns:
A reference to the object


The documentation for this class was generated from the following files:
Generated on Wed Mar 5 23:10:36 2008 for NemesisUtilitiesSystem by  doxygen 1.5.4