InetAddress Class Reference

An IPv4 Internet address. More...

#include <InetAddress.h++>

Collaboration diagram for InetAddress:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 InetAddress () throw ()
 Construct a new, wildcard InetAddress.
 InetAddress (const String &host)
 Construct a new InetAddress for the given host name.
 InetAddress (uint32_t addr) throw ()
 Construct a new, InetAddress for the given IP address.
 InetAddress (byte_t addr[4]) throw ()
 Construct a new, InetAddress for the given IP address.
 ~InetAddress () throw ()
 Destructor.
void setHost (const String &host) throw (HostNotFoundException)
 Set the hostname for this address.
void setAddress (uint32_t addr) throw ()
 Set the host IP address for this address.
uint32_t getAddress () const throw ()
 Get the host IP address for this address.
char getNetworkClass () const throw ()
 Get the network class for the IP address.
bool isMulticast () const throw ()
 Test if the IP address is a multicast address (range 224.0.0.0 through 239.255.255.255, also known as class "D").
bool isNonroutable () const throw ()
 Test if the IP address is non-routable (one of 10.x.x.x, 192.168.x.x, or 172.16.x.x - 172.31.x.x).
bool isLinkLocal () const throw ()
 Test if the IP address is a link-local address (169.254.x.x).
String getHost () const throw (HostNotFoundException)
 Get the host name for this address.
void resolve () throw (HostNotFoundException)
 If the InetAddress was constructed with a host (DNS) name, attempt to resolve the name to an IP address.
bool isResolved () const throw ()
 Test if this InetAddress has been successfully resolved.
String toString () const
 Get a String representation for this address.
String toIPString () const
 Get a String representation for this address in dot-separated form.
bool operator== (const InetAddress &other) const throw ()
 Equality operator.
bool operator!= (const InetAddress &other) const throw ()
 Inequality operator.
InetAddressoperator|= (const InetAddress &other) throw ()
 Bitwise-OR another address with this address.
InetAddressoperator&= (const InetAddress &other) throw ()
 Bitwise-AND another address with this address.

Static Public Attributes

static const InetAddress ANY
 A value representing the wildcard address, 0.0.0.0.


Detailed Description

An IPv4 Internet address.

Author:
Mark Lindner

Constructor & Destructor Documentation

InetAddress (  )  throw ()

Construct a new, wildcard InetAddress.

InetAddress ( const String host  )  [explicit]

Construct a new InetAddress for the given host name.

The address will not be valid until the hostname is resolved via a call to resolve().

Parameters:
host The host name; either a DNS name or a dot-separated IP address.

InetAddress ( uint32_t  addr  )  throw () [explicit]

Construct a new, InetAddress for the given IP address.

Parameters:
addr The IP address, represented as a 32-bit integer in host byte order.

InetAddress ( byte_t  addr[4]  )  throw () [explicit]

Construct a new, InetAddress for the given IP address.

Parameters:
addr The IP address, represented as a 4-byte tuple.

~InetAddress (  )  throw ()

Destructor.


Member Function Documentation

uint32_t getAddress (  )  const throw () [inline]

Get the host IP address for this address.

Returns:
The IP address, packed in a 32-bit integer in host byte order.

String getHost (  )  const throw (HostNotFoundException)

Get the host name for this address.

If necessary, a reverse DNS lookup is done. If that fails, the host is returned in dot-separated form.

char getNetworkClass (  )  const throw ()

Get the network class for the IP address.

Returns:
The class, as a character in the range 'A' - 'E', or '?' if the address is not a member of any class (e.g., 0.0.0.0).

bool isLinkLocal (  )  const throw ()

Test if the IP address is a link-local address (169.254.x.x).

bool isMulticast (  )  const throw ()

Test if the IP address is a multicast address (range 224.0.0.0 through 239.255.255.255, also known as class "D").

bool isNonroutable (  )  const throw ()

Test if the IP address is non-routable (one of 10.x.x.x, 192.168.x.x, or 172.16.x.x - 172.31.x.x).

bool isResolved (  )  const throw () [inline]

Test if this InetAddress has been successfully resolved.

bool operator!= ( const InetAddress other  )  const throw () [inline]

Inequality operator.

InetAddress & operator&= ( const InetAddress other  )  throw ()

Bitwise-AND another address with this address.

bool operator== ( const InetAddress other  )  const throw ()

Equality operator.

InetAddress & operator|= ( const InetAddress other  )  throw ()

Bitwise-OR another address with this address.

void resolve (  )  throw (HostNotFoundException)

If the InetAddress was constructed with a host (DNS) name, attempt to resolve the name to an IP address.

Exceptions:
HostNotFoundException If the host name could not be resolved.

void setAddress ( uint32_t  addr  )  throw ()

Set the host IP address for this address.

Parameters:
addr The IP address, packed in a 32-bit integer.

void setHost ( const String host  )  throw (HostNotFoundException)

Set the hostname for this address.

Parameters:
host The host, as a dot-separated IP address or DNS name.

String toIPString (  )  const

Get a String representation for this address in dot-separated form.

String toString (  )  const

Get a String representation for this address.


Member Data Documentation

const InetAddress ANY [static]

A value representing the wildcard address, 0.0.0.0.


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

Generated on Sat Apr 17 23:03:08 2010 for libcommonc++ by  doxygen 1.5.9