libcommonc++  0.7
InetAddress Class Reference

An IPv4 Internet address. More...

#include <InetAddress.h++>

Collaboration diagram for InetAddress:

Public Member Functions

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

Static Public Attributes

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

Detailed Description

An IPv4 Internet address.

Author
Mark Lindner

Constructor & Destructor Documentation

◆ InetAddress() [1/4]

Construct a new, wildcard InetAddress.

◆ InetAddress() [2/4]

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
hostThe host name; either a DNS name or a dot-separated IP address.

◆ InetAddress() [3/4]

InetAddress ( uint32_t  addr)
explicit

Construct a new, InetAddress for the given IP address.

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

◆ InetAddress() [4/4]

InetAddress ( byte_t  addr[4])
explicit

Construct a new, InetAddress for the given IP address.

Parameters
addrThe IP address, represented as a 4-byte tuple.

◆ ~InetAddress()

Destructor.

Member Function Documentation

◆ getAddress()

uint32_t getAddress ( ) const
inline

Get the host IP address for this address.

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

◆ getHost()

String getHost ( ) const

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.

Exceptions
HostNotFoundExceptionIf the hostname could not be resolved.

◆ getNetworkClass()

char getNetworkClass ( ) const

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).

◆ isLinkLocal()

bool isLinkLocal ( ) const

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

◆ isMulticast()

bool isMulticast ( ) const

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

◆ isNonroutable()

bool isNonroutable ( ) const

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).

◆ isResolved()

bool isResolved ( ) const
inline

Test if this InetAddress has been successfully resolved.

◆ operator &=()

InetAddress& operator&= ( const InetAddress other)

Bitwise-AND another address with this address.

◆ operator!=()

bool operator!= ( const InetAddress other) const
inline

Inequality operator.

◆ operator==()

bool operator== ( const InetAddress other) const

Equality operator.

◆ operator|=()

InetAddress & operator|= ( const InetAddress other)

Bitwise-OR another address with this address.

◆ resolve()

void resolve ( )

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

Exceptions
HostNotFoundExceptionIf the host name could not be resolved.

◆ setAddress()

void setAddress ( uint32_t  addr)

Set the host IP address for this address.

Parameters
addrThe IP address, packed in a 32-bit integer.

◆ setHost()

void setHost ( const String host)

Set the hostname for this address.

Parameters
hostThe host, as a dot-separated IP address or DNS name.
Exceptions
HostNotFoundExceptionIf the hostname cannot be resolved.

◆ toIPString()

String toIPString ( ) const

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

◆ toString()

String toString ( ) const

Get aString representation for this address.

Member Data Documentation

◆ ANY

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: