Skip navigation links

Overview | Package | Class | Tree | Index | Help
| Oracle® Coherence Java API Reference Release 3.6.1.0 E18814-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.tangosol.net
Class InetAddressHelper

`java.lang.Object
com.tangosol.util.Base
com.tangosol.net.InetAddressHelper`

      public abstract class InetAddressHelper

extends Base

Helper class that encapsulates common InetAddress functionality.

Field Summary
`static java.lang.reflect.Method` | `METHOD_GET_MTU` Method for obtaining the MTU from a NetworkInterface in 1.6+ JVMs.
`static boolean` | `PreferIPv4Stack` The value of system property "java.net.preferIPv4Stack".
`static boolean` | `PreferIPv6Addresses` The value of system property "java.net.preferIPv6Addresses".

Constructor Summary
`InetAddressHelper()`

Method Summary
`static int` | `compare(java.net.InetAddress addrA, java.net.InetAddress addrB)` Compare two InetAddresses for ordering purposes.
`static java.util.List` | `getAllLocalAddresses()` Return a list of all InetAddress objects bound to all the network interfaces on this machine.
`static java.util.Map` | `getAllLocalMTUs()` Return a map of all InetAddress and MTUs bound to all the network interfaces on this machine.
`static java.net.InetAddress` | `getByAddress(byte[] abAddr)` Return an InetAddress object given the raw IP address.
`static java.net.InetAddress` | `getLocalHost()` Obtain the local host address.
`static int` | `getLocalMTU(java.net.InetAddress addr)` Return the MTU for the specified local address.
`static int` | `getLocalMTU(java.net.NetworkInterface ni)` Return the MTU for the specified NetworkInterface.
`static boolean` | `isAnyLocalAddress(java.net.InetAddress addr)` Deprecated. As of Coherence 3.0, replaced by `InetAddress.isAnyLocalAddress()`
`static boolean` | `isLinkLocalAddress(java.net.InetAddress addr)` Deprecated. As of Coherence 3.0, replaced by `InetAddress.isLinkLocalAddress()`
`static boolean` | `isLoopbackAddress(java.net.InetAddress addr)` Deprecated. As of Coherence 3.0, replaced by `InetAddress.isLoopbackAddress()`
`static boolean` | `isSiteLocalAddress(java.net.InetAddress addr)` Deprecated. As of Coherence 3.0, replaced by `InetAddress.isSiteLocalAddress()`
`static long` | `toLong(java.net.InetAddress addr)` Converts an IPv4 compatible address to a long value.
`static java.lang.String` | `toString(byte[] ab)` Converts a byte array to a raw IP address string representation.
`static java.lang.String` | `toString(java.net.InetAddress addr)` Format an IP address string representing the specified InetAddress object.
`static boolean` | `virtuallyEqual(byte[] abAddr1, byte[] abAddr2)` Compare specified raw IP addresses taking into account IPv4-compatible IPv6 addresses.

Field Detail

### PreferIPv4Stack

    public static final boolean PreferIPv4Stack

  The value of system property "java.net.preferIPv4Stack".
  See Also:
    Networking IPv6 User Guide

### PreferIPv6Addresses

    public static final boolean PreferIPv6Addresses

  The value of system property "java.net.preferIPv6Addresses".
  See Also:
    Networking IPv6 User Guide

### METHOD_GET_MTU

    public static final java.lang.reflect.Method METHOD_GET_MTU

  Method for obtaining the MTU from a NetworkInterface in 1.6+ JVMs.

Constructor Detail

### InetAddressHelper

    public InetAddressHelper()

Method Detail

### getLocalHost

    public static java.net.InetAddress getLocalHost()
                                             throws java.net.UnknownHostException

  Obtain the local host address. If at all possible, ensure that the returned address is not a loopback, wildcard or a link local address.
  Returns:
    the InetAddress that is the best fit for the local host address
  Throws:
    `java.net.UnknownHostException`
  See Also:
    Sun's Bug Parade

### compare

    public static int compare(java.net.InetAddress addrA,
                              java.net.InetAddress addrB)

  Compare two InetAddresses for ordering purposes.
  Parameters:
    `addrA` - the first address to compare
    `addrB` - the second address to compare
  Returns:
    a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second

### getLocalMTU

    public static int getLocalMTU(java.net.InetAddress addr)

  Return the MTU for the specified local address.
  Parameters:
    `addr` - the local address
  Returns:
    the MTU of the specified address, or 0 if the MTU can not be identified

### getLocalMTU

    public static int getLocalMTU(java.net.NetworkInterface ni)

  Return the MTU for the specified NetworkInterface.
  Parameters:
    `ni` - the network interface
  Returns:
    the MTU of the specified address, or 0 if the MTU can not be identified

### getAllLocalAddresses

    public static java.util.List getAllLocalAddresses()

  Return a list of all InetAddress objects bound to all the network interfaces on this machine.
  Returns:
    a list of InetAddress objects

### getAllLocalMTUs

    public static java.util.Map getAllLocalMTUs()

  Return a map of all InetAddress and MTUs bound to all the network interfaces on this machine. If the MTU cannot be obtained a null value will be used.
  Returns:
    a map of Integer MTU values keyed by the corresponding InetAddress

### isLoopbackAddress

    @Deprecated
    public static boolean isLoopbackAddress(java.net.InetAddress addr)

  Deprecated. As of Coherence 3.0, replaced by `InetAddress.isLoopbackAddress()`
  Check whether or not the specified address is a loopback address.
  Parameters:
    `addr` - the InetAddress
  Returns:
    true iff the address is a loopback address

### isAnyLocalAddress

    @Deprecated
    public static boolean isAnyLocalAddress(java.net.InetAddress addr)

  Deprecated. As of Coherence 3.0, replaced by `InetAddress.isAnyLocalAddress()`
  Check whether or not the specified address is a wildcard address.
  Parameters:
    `addr` - the InetAddress
  Returns:
    true iff the address is a wildcard address

### isLinkLocalAddress

    @Deprecated
    public static boolean isLinkLocalAddress(java.net.InetAddress addr)

  Deprecated. As of Coherence 3.0, replaced by `InetAddress.isLinkLocalAddress()`
  Check whether or not the specified address is a link local address.
  Parameters:
    `addr` - the InetAddress
  Returns:
    true iff the address is a link local address

### isSiteLocalAddress

    @Deprecated
    public static boolean isSiteLocalAddress(java.net.InetAddress addr)

  Deprecated. As of Coherence 3.0, replaced by `InetAddress.isSiteLocalAddress()`
  Check whether or not the specified address is a site local address.
  Parameters:
    `addr` - the InetAddress
  Returns:
    true iff the address is a site local address

### getByAddress

    public static java.net.InetAddress getByAddress(byte[] abAddr)
                                             throws java.net.UnknownHostException

  Return an InetAddress object given the raw IP address.
  Parameters:
    `abAddr` - the raw IP address in network byte order
  Returns:
    the InetAddress object
  Throws:
    `java.net.UnknownHostException`

### virtuallyEqual

    public static boolean virtuallyEqual(byte[] abAddr1,
                                         byte[] abAddr2)

  Compare specified raw IP addresses taking into account IPv4-compatible IPv6 addresses. Two addresses are considered virtually equal if they have the same protocol (length) and are equal, or if one of them is an IPv6 address that is IPv4-compatible and its IPv4 representation is equal to the other IPv4 address.
  Parameters:
    `abAddr1` - first IP address
    `abAddr2` - second IP address
  Returns:
    true iff the addresses are compatible

### toLong

    public static long toLong(java.net.InetAddress addr)

  Converts an IPv4 compatible address to a long value.
  Parameters:
    `addr` - an instance of InetAddress to convert to a long
  Returns:
    a long value holding the IPv4 address

### toString

    public static java.lang.String toString(byte[] ab)

  Converts a byte array to a raw IP address string representation. The format of the address string is one of the following:
  - "d.d.d.d" for IPv4 address
  - "::d.d.d.d" for IPv4 compatible IPv6 address
  - "x:x:x:x:x:x:d.d.d.d" for generic IPv6 address
  Parameters:
    `ab` - the byte array holding the IP address
  Returns:
    the IP address string
  See Also:
    `InetAddress.getHostAddress()`, `Inet6Address`

### toString

    public static java.lang.String toString(java.net.InetAddress addr)

  Format an IP address string representing the specified InetAddress object. The main difference if this method over the `addr.toString()` call is that this implementation avoids a call to the `addr.getHostName()` method, which could be very expensive due to the reverse DNS lookup.
  For IPv6 addresses this method produces an alternative form of "x:x:x:x:x:x:d.d.d.d" and a compressed form of "::d.d.d.d" for IPv4 compatible addresses (instead of the default form "x:x:x:x:x:x:x:x").
  Parameters:
    `addr` - the address for which to format the IP address string
  Returns:
    the IP address string
  See Also:
    `InetAddress.getHostAddress()`, `Inet6Address`

Skip navigation links

Overview | Package | Class | Tree | Index | Help
| Oracle® Coherence Java API Reference Release 3.6.1.0 E18814-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.