Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

Cabal::Address Class Reference

Internet address abstract representation. More...

#include <cabal_address.h>

List of all members.

Public Member Functions

 Address (const std::string &c_address, const NetPort nPort=0)
 Address (const char *c_address, const NetPort nPort=0)
 Address (const Address &src)
 Address (const SockAddrInet &addr)
void set (const std::string &str, const NetPort nPort=0)
void set (const char *str, const NetPort nPort=0)
void set (const SockAddrInet &addr)
void copy (const Address &addr)
Addressclone ()
const std::string & host ()
void host (const std::string &h)
 Changes the internal host name.

const char * ip ()
const SockAddrInet & address () const
 Returns a const version of the internal address.

SockAddrInet & varAddress ()
 Returns read-write version of the address.

void invalidate ()
 Makes the addres representation strings no longer valid.

StringList * listOfIps () const
 Returns a newly allocated list containings all the ips in quad-dot format.

const NetAddr * aliasIpList () const
int port () const
void port (const int nPort)
bool isReady () const
bool Address::scan ()
 Scan the network searching for the m_host field.

bool Address::scan (const std::string &host)
 Scan the network searching for the m_host field.

void operator= (const Address &orig)
 Copy operator.

bool operator== (const Address &a2) const
bool operator!= (const Address &a2) const


Detailed Description

Internet address abstract representation.

This class encapsulates an internet address (Net::SockAddrInet, generally mapping to underlying system "struct sockaddr_in") and various methods that can be done on that:

Definition at line 32 of file cabal_address.h.


Member Function Documentation

const SockAddrInet& Cabal::Address::address  )  const [inline]
 

Returns a const version of the internal address.

Read-only version.

Definition at line 139 of file cabal_address.h.

Referenced by Cabal::Socket::bind(), Cabal::TCPSocket::connect(), Cabal::UDPSocket::rawSend(), and Cabal::UDPSocket::sendTo().

bool Cabal::Address::Address::scan const std::string &  host  )  [inline]
 

Scan the network searching for the m_host field.

Resolves to a call to scan() after having set the host.

Definition at line 202 of file cabal_address.h.

bool Cabal::Address::Address::scan  )  [inline]
 

Scan the network searching for the m_host field.

If an host name has been given, this searches the net for corresponding ip or ip list. If an entry is found, the internall address reference is updated; up to 5 secondary ips are fetched.

On failure it returns null.

If the host element of this address is not set, it makes an assertion to fail and terminates your program.

Definition at line 192 of file cabal_address.h.

References Address::scan(), and host().

Referenced by Address::scan().

void Cabal::Address::host const std::string &  h  )  [inline]
 

Changes the internal host name.

This also clears all the internal data, as this function is to be used ONLY when there is a subquesent need to scan (search for) the host.

Definition at line 121 of file cabal_address.h.

Referenced by Address::scan().

void Cabal::Address::invalidate  )  [inline]
 

Makes the addres representation strings no longer valid.

This forces to re-create representation strings on request for ip() and/or host() methods.

Definition at line 161 of file cabal_address.h.

Referenced by varAddress().

StringList * Cabal::Address::listOfIps  )  const
 

Returns a newly allocated list containings all the ips in quad-dot format.

For logging or debugging purposes, this function provides the caller with a StringList (std::list< std::string > ) containing all the quad-dot strings bound with this ip, provided it has been scanned. it returns null.

Freeing the list is responsibilty of the caller.

Returns:
a new list of dot-quad entries referring to this address, or 0.

Definition at line 19 of file ltlib/cabal_address.cpp.

void Cabal::Address::operator= const Address orig  )  [inline]
 

Copy operator.

This operator returns void so that it not breaks internal m_address const correctness.

Definition at line 211 of file cabal_address.h.

SockAddrInet& Cabal::Address::varAddress  )  [inline]
 

Returns read-write version of the address.

This also invalidates the address, causing ips representation and eventually host name to be recalculate on request.

Be carefull using this method in multithreading because if you don't pay attention, some other threads may re-validate the address even before the calling thread is able to change the value in the address.

Definition at line 151 of file cabal_address.h.

References invalidate().

Referenced by Cabal::UDPSocket::rawRecv(), and Cabal::UDPSocket::recvFrom().


The documentation for this class was generated from the following files:
Generated on Sat Apr 10 17:41:49 2004 for Cabal by doxygen 1.3.5