Oracle® Fusion Middleware C++ API Reference for Oracle Coherence
12c (12.2.1.3.0)

E80355-01

InetAddress Class Reference

#include <coherence/net/InetAddress.hpp>

Inherits Object.

List of all members.


Detailed Description

InetAddress represents an IP address.

Author:
mf 2008.03.17

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);
     }

Returns:
a string representation of this object

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 hashCode is:

  • Whenever it is invoked on the same Object more than once during an execution of an application, the hashCode method must consistently return the same value, provided no information used in equals comparisons on the object is modified. This value need not remain consistent from one execution of an application to another execution of the same application.
  • If two Objects are equal according to the equals method, then calling the hashCode method on each of the two Objects must produce the same value.
  • It is not required that if two Objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct results. However, the programmer should be aware that producing distinct results for unequal objects may improve the performance of hash-based containers.

The default implementation is identity based.

Returns:
a hash code value for this Object


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.

Constructor & Destructor Documentation

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.

Parameters:
vsName the name of the host
vaIP the array representation of the host's IP address.


Member Function Documentation

static InetAddress::View getLocalHost (  )  [static]

Return the InetAddress for the local machine.

Returns:
the local InetAddress.

static InetAddress::View getByName ( String::View  vsHost  )  [static]

Return the InetAddress for the specified machine name.

Parameters:
vHost the name or IP of the host to resolve
Returns:
the InetAddress for the specified machine name

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.

Parameters:
vsHost the name of the host, or NULL
Returns:
an array of all the IP addresses for a given host name
Exceptions:
UnknownHostException if no IP address for the vsHost could be found.
Since:
12.2.1

static InetAddress::View getLoopbackAddress (  )  [static]

Returns the loopback address.

Returns:
the InetAddress loopback instance
Since:
12.2.1

virtual String::View getHostName (  )  const [virtual]

Return the hostname associated with this address.

Returns:
the hostname associated with this address

virtual String::View getHostAddress (  )  const [virtual]

Return the address in textual form.

Returns:
the address in textual form

virtual Array<octet_t>::View getAddress (  )  const [virtual]

Return the raw IP address, in network byte order, with the highest order byte stored at index zero.

Returns:
the raw IP address


The documentation for this class was generated from the following file:
Copyright © 2000, 2017, Oracle and/or its affiliates. All rights reserved.