Class Overview
This class represents a 32 bit long IPv4 address. The most common textual
representation of an IPv4 address follows the pattern b.b.b.b
where
each b
represents one of the four bytes. If only three parts are
specified (b.b.bb
), the last part is then 16 bit long, the address
represents a class B network address as 128.net.host. A two part
address (b.bbb
) allows to represent a class A network address as
net.host. If there is only one part (bbbb
) the address is
represented without any byte rearrangement.
Summary
Public Methods |
boolean
|
isAnyLocalAddress()
Returns whether the represented address is the local wildcard ANY address
or not.
|
boolean
|
isLinkLocalAddress()
Returns whether this address has a link-local scope or not.
|
boolean
|
isLoopbackAddress()
Returns whether the represented address is a loopback address or not.
|
boolean
|
isMCGlobal()
Returns whether the address is a global multicast address or not.
|
boolean
|
isMCLinkLocal()
Returns whether the address is a link-local multicast address or not.
|
boolean
|
isMCNodeLocal()
Returns whether the address has a node-local scope or not.
|
boolean
|
isMCOrgLocal()
Returns whether the address is a organization-local multicast address or
not.
|
boolean
|
isMCSiteLocal()
Returns whether the address is a site-local multicast address or not.
|
boolean
|
isMulticastAddress()
Returns whether the represented address is a multicast address or not.
|
boolean
|
isSiteLocalAddress()
Returns whether this address has a site-local scope or not.
|
[Expand]
Inherited Methods |
From class java.net.InetAddress
boolean
|
equals(Object obj)
Compares this InetAddress instance against the specified address
in obj .
|
byte[]
|
getAddress()
Returns the IP address represented by this InetAddress instance
as a byte array.
|
static
InetAddress[]
|
getAllByName(String host)
Gets all IP addresses associated with the given host identified
by name or literal IP address.
|
static
InetAddress
|
getByAddress(String hostName, byte[] ipAddress)
Returns the InetAddress corresponding to the array of bytes, and
the given hostname.
|
static
InetAddress
|
getByAddress(byte[] ipAddress)
Returns the InetAddress corresponding to the array of bytes.
|
static
InetAddress
|
getByName(String host)
Returns the address of a host according to the given host string name
host .
|
String
|
getCanonicalHostName()
Gets the fully qualified domain name for the host associated with this IP
address.
|
String
|
getHostAddress()
Gets the textual representation of this IP address.
|
String
|
getHostName()
Gets the host name of this IP address.
|
static
InetAddress
|
getLocalHost()
Returns an InetAddress for the local host if possible, or the
loopback address otherwise.
|
int
|
hashCode()
Gets the hashcode of the represented IP address.
|
boolean
|
isAnyLocalAddress()
Returns whether this is a wildcard address or not.
|
boolean
|
isLinkLocalAddress()
Returns whether this address is a link-local address or not.
|
boolean
|
isLoopbackAddress()
Returns whether this address is a loopback address or not.
|
boolean
|
isMCGlobal()
Returns whether this address is a global multicast address or not.
|
boolean
|
isMCLinkLocal()
Returns whether this address is a link-local multicast address or not.
|
boolean
|
isMCNodeLocal()
Returns whether this address is a node-local multicast address or not.
|
boolean
|
isMCOrgLocal()
Returns whether this address is a organization-local multicast address or
not.
|
boolean
|
isMCSiteLocal()
Returns whether this address is a site-local multicast address or not.
|
boolean
|
isMulticastAddress()
|
boolean
|
isReachable(int timeout)
Tries to reach this InetAddress .
|
boolean
|
isReachable(NetworkInterface netif, int ttl, int timeout)
Tries to reach this InetAddress .
|
boolean
|
isSiteLocalAddress()
Returns whether this address is a site-local address or not.
|
String
|
toString()
Returns a string containing a concise, human-readable description of this
IP address.
|
|
From class java.lang.Object
Object
|
clone()
Creates and returns a copy of this Object .
|
boolean
|
equals(Object o)
Compares this instance with the specified object and indicates if they
are equal.
|
void
|
finalize()
Is called before the object's memory is being reclaimed by the VM.
|
final
Class<? extends Object>
|
getClass()
Returns the unique instance of Class which represents this
object's class.
|
int
|
hashCode()
Returns an integer hash code for this object.
|
final
void
|
notify()
Causes a thread which is waiting on this object's monitor (by means of
calling one of the wait() methods) to be woken up.
|
final
void
|
notifyAll()
Causes all threads which are waiting on this object's monitor (by means
of calling one of the wait() methods) to be woken up.
|
String
|
toString()
Returns a string containing a concise, human-readable description of this
object.
|
final
void
|
wait(long millis, int nanos)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait(long millis)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait()
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.
|
|
Public Methods
public
boolean
isAnyLocalAddress
()
Returns whether the represented address is the local wildcard ANY address
or not.
Returns
true
if this instance represents the wildcard ANY
address, false
otherwise.
public
boolean
isLinkLocalAddress
()
Returns whether this address has a link-local scope or not.
RFC 3484
Default Address Selection for Internet Protocol Version 6 (IPv6) states
IPv4 auto-configuration addresses, prefix 169.254/16, IPv4 loopback
addresses, prefix 127/8, are assigned link-local scope.
Returns
true
if this instance represents a link-local address,
false
otherwise.
public
boolean
isLoopbackAddress
()
Returns whether the represented address is a loopback address or not.
Loopback IPv4 addresses are prefixed with: 011111111 = 127.
Returns
true
if this instance represents a lookback address,
false
otherwise.
public
boolean
isMCGlobal
()
Returns whether the address is a global multicast address or not. Valid
MCGlobal IPv4 addresses are 224.0.1.0 - 238.255.255.255.
Returns
true
if the address is in the global multicast group,
false
otherwise.
public
boolean
isMCLinkLocal
()
Returns whether the address is a link-local multicast address or not. The
valid range for IPv4 link-local addresses is: 224.0.0.0 to 239.0.0.255
Hence a mask of 111000000000000000000000 = 0xE00000.
Returns
true
if this instance represents a link-local address,
false
otherwise.
public
boolean
isMCNodeLocal
()
Returns whether the address has a node-local scope or not. This method
returns always false
because there are no valid IPv4 node-local
addresses.
Returns
false
for all IPv4 addresses.
public
boolean
isMCOrgLocal
()
Returns whether the address is a organization-local multicast address or
not. The valid range for IPv4 organization-local addresses is:
239.192.0.0 to 239.195.255.255 Hence masks of 11101111 11000000 to
11101111 11000011 are valid. 0xEFC0 to 0xEFC3
Returns
true
if this instance represents a organization-local
address, false
otherwise.
public
boolean
isMCSiteLocal
()
Returns whether the address is a site-local multicast address or not. The
valid range for IPv4 site-local addresses is: 239.255.0.0 to
239.255.255.255 Hence a mask of 11101111 11111111 = 0xEFFF.
Returns
true
if this instance represents a site-local address,
false
otherwise.
public
boolean
isMulticastAddress
()
Returns whether the represented address is a multicast address or not.
Valid IPv4 multicast addresses are prefixed with 1110 = 0xE.
Returns
true
if this instance represents a multicast address,
false
otherwise.
public
boolean
isSiteLocalAddress
()
Returns whether this address has a site-local scope or not.
RFC 3484
Default Address Selection for Internet Protocol Version 6 (IPv6) states
IPv4 private addresses, prefixes 10/8, 172.16/12, and 192.168/16, are
assigned site-local scope.
Returns
true
if this instance represents a site-local address,
false
otherwise.