#include <coherence/net/InetAddress.hpp>
Inherits Object.
Public Types | |
typedef spec::Handle | Handle |
InetAddress Handle definition. | |
typedef spec::View | View |
InetAddress View definition. | |
typedef spec::Holder | Holder |
InetAddress Holder definition. | |
Public Member Functions | |
virtual String::View | getHostName () const |
Return the hostname associated with this address. | |
virtual String::View | getHostAddress () const |
Return the address in textual form. | |
virtual Array < octet_t >::View | getAddress () const |
Return the raw IP address, in network byte order, with the highest order byte stored at index zero. | |
virtual TypedHandle < const String > | toString () const |
Output a human-readable description of this Object to the given stream. Note that when overriding this method the return type must be TypedHandle<const String> rather then String::View. These two types are assignment compatible but not equivalent and declaring the override with String::View will not be a compatible override. coherence::lang::operator<<(std::ostream, Object::View) is defined and will call into the toString method, to output Objects. If a managed String object is desired, the COH_TO_STRING macro can be used to build up a String from streamable contents and is generally how toString() will be implemented.
Object::View vKey = ... Object::View vValue = ... std::cout << vKey << " = " << vValue << std::endl; String::View vs = COH_TO_STRING(vKey << " = " << vValue); The COH_TO_STRING macro is also the most common way to implement the toString method. For example:
virtual TypedHandle<const String> Person::toString() const { return COH_TO_STRING("Name: " << f_sName << " SSN: " << f_nSSN); }
| |
virtual bool | equals (Object::View that) const |
virtual size32_t | hashCode () const |
Return a hash code value for the Object. This method is supported for the benefit of hash-based containers.
The general contract of
The default implementation is identity based.
| |
Static Public Member Functions | |
static InetAddress::View | getLocalHost () |
Return the InetAddress for the local machine. | |
static InetAddress::View | getByName (String::View vsHost) |
Return the InetAddress for the specified machine name. | |
static ObjectArray::Handle | getAllByName (String::View vsHost) |
Given the name of a host, returns an array of its IP addresses, based on the configured name service on the system. | |
static InetAddress::View | getLoopbackAddress () |
Returns the loopback address. | |
Protected Member Functions | |
InetAddress (String::View vsHost, Array< octet_t >::View vaIP) | |
Manually construct an InetAddress from a network byte ordered array. | |
InetAddress (const InetAddress &) | |
Copy Constructor. |
InetAddress | ( | String::View | vsHost, | |
Array< octet_t >::View | vaIP | |||
) | [protected] |
Manually construct an InetAddress from a network byte ordered array.
It is recommended that the getByName() method be used in place of manual InetAddress construction.
vsName | the name of the host | |
vaIP | the array representation of the host's IP address. |
static InetAddress::View getLocalHost | ( | ) | [static] |
static InetAddress::View getByName | ( | String::View | vsHost | ) | [static] |
Return the InetAddress for the specified machine name.
vHost | the name or IP of the host to resolve |
static ObjectArray::Handle getAllByName | ( | String::View | vsHost | ) | [static] |
Given the name of a host, returns an array of its IP addresses, based on the configured name service on the system.
If the host is NULL then an InetAddress representing an address of the loopback interface is returned.
vsHost | the name of the host, or NULL |
UnknownHostException | if no IP address for the vsHost could be found. |
static InetAddress::View getLoopbackAddress | ( | ) | [static] |
virtual String::View getHostName | ( | ) | const [virtual] |
Return the hostname associated with this address.
virtual String::View getHostAddress | ( | ) | const [virtual] |
Return the address in textual form.
Return the raw IP address, in network byte order, with the highest order byte stored at index zero.