A Dv::Net::InetAddress object represents a valid internet host. More...
#include <inetaddress.h>
Public Member Functions | |
~InetAddress () | |
bool | operator== (const InetAddress &) const |
const char * | host () const |
Find alphabetic hostname of this address. | |
unsigned long | address () const |
const std::string & | dot_address () const |
Static Public Member Functions | |
static Dv::shared_ptr < InetAddress > | by_name (const std::string &host) |
Factory method: return ref<InetAddress> corresponding with host or 0. | |
static Dv::shared_ptr < InetAddress > | by_address (unsigned long addr) |
Factory method: return ref<InetAddress> corresponding with addr or 0. | |
static std::string | local_host () |
Private Member Functions | |
InetAddress (const char *, unsigned long, const char *) | |
Private constructor. | |
Static Private Member Functions | |
static const char * | host_name_from_address (unsigned long addr) |
Use gethostbyaddr to find the hostname. | |
Private Attributes | |
const char * | host_ |
unsigned long | address_ |
std::string | dot_address_ |
A Dv::Net::InetAddress object represents a valid internet host.
Definition at line 17 of file inetaddress.h.
Dv::Net::InetAddress::~InetAddress | ( | ) |
Dv::Net::InetAddress::InetAddress | ( | const char * | , | |
unsigned | long, | |||
const char * | ||||
) | [private] |
Private constructor.
static Dv::shared_ptr<InetAddress> Dv::Net::InetAddress::by_name | ( | const std::string & | host | ) | [static] |
Factory method: return ref<InetAddress> corresponding with host or 0.
host | string representation of host, of the form "tinf2.vub.ac.be" or "134.184.65.2". "localhost" is also a valid argument. |
Example usage:
static Dv::shared_ptr<InetAddress> Dv::Net::InetAddress::by_address | ( | unsigned long | addr | ) | [static] |
Factory method: return ref<InetAddress> corresponding with addr or 0.
Note that this function does not automatically fill in the alphabetic host, in order not to do a possibly superfluous DNS query.
addr | numeric internet address |
bool Dv::Net::InetAddress::operator== | ( | const InetAddress & | ) | const |
const char* Dv::Net::InetAddress::host | ( | ) | const |
Find alphabetic hostname of this address.
Note that, if the Dv::Net::InetAddress object was created using Dv::Net::InetAddress::by_address, this call may result in a DNS query. This is because the (alphabetic) host is only obtained ``on demand'', i.e. by calling this function. This feature was introduced to avoid unnecessary DNS queries.
unsigned long Dv::Net::InetAddress::address | ( | ) | const [inline] |
Definition at line 61 of file inetaddress.h.
References address_.
const std::string& Dv::Net::InetAddress::dot_address | ( | ) | const [inline] |
Definition at line 63 of file inetaddress.h.
References dot_address_.
static std::string Dv::Net::InetAddress::local_host | ( | ) | [static] |
static const char* Dv::Net::InetAddress::host_name_from_address | ( | unsigned long | addr | ) | [static, private] |
Use gethostbyaddr to find the hostname.
const char* Dv::Net::InetAddress::host_ [mutable, private] |
Definition at line 67 of file inetaddress.h.
unsigned long Dv::Net::InetAddress::address_ [private] |
Definition at line 68 of file inetaddress.h.
Referenced by address().
std::string Dv::Net::InetAddress::dot_address_ [private] |
Definition at line 69 of file inetaddress.h.
Referenced by dot_address().
dvnet-0.9.24 | [ 5 December, 2009] |