| java.lang.Object java.net.InetAddress
All known Subclasses: java.net.Inet6Address, java.net.Inet4Address,
InetAddress | public class InetAddress extends Object implements Serializable(Code) | | The Internet Protocol (IP) address class. This class encapsulates an IP
address and provides name and reverse name resolution functions. The address
is stored in network order, but as a signed (rather than unsigned) integer.
|
Inner Class :class CacheElement | |
Inner Class :static class Cache | |
Constructor Summary | |
| InetAddress() Constructs an InetAddress. | | InetAddress(byte[] address) Constructs an InetAddress, representing the address and
hostName . | | InetAddress(byte[] address, String hostName) Constructs an InetAddress, representing the address and
hostName . |
Method Summary | |
static int | bytesToInt(byte bytes, int start) Takes the byte array and creates an integer out of four bytes starting at
start as the high-order byte. | CacheElement | cacheElement() | static InetAddress | createHostNameFromIPAddress(String ipAddressString) Creates an InetAddress based on an ipAddressString. | public boolean | equals(Object obj) Compares this InetAddress against the specified object. | public byte[] | getAddress() Returns the IP address of this InetAddress as an array. | native static InetAddress[] | getAliasesByNameImpl(String name) Query the IP stack for aliases for the host. | public static InetAddress[] | getAllByName(String host) Answer the IP addresses of a named host. | public static InetAddress | getByAddress(byte[] ipAddress) Answers the InetAddress corresponding to the array of bytes. | static InetAddress | getByAddress(byte[] ipAddress, int scope_id) Answers the InetAddress corresponding to the array of bytes. | public static InetAddress | getByAddress(String hostName, byte[] ipAddress) Answers the InetAddress corresponding to the array of bytes, and the
given hostname. | static InetAddress | getByAddressInternal(String hostName, byte[] ipAddress, int scope_id) Answers the InetAddress corresponding to the array of bytes, and the
given hostname. | public static InetAddress | getByName(String host) Answers the address of a host, given a host string name. | public String | getCanonicalHostName() | public String | getHostAddress() Answer the dotted string IP address representing this address. | native static InetAddress | getHostByAddrImpl(byte[] addr) Query the IP stack for the host address. | native static InetAddress | getHostByNameImpl(String name, boolean preferIPv6Address) Query the IP stack for the host address. | public String | getHostName() Answer the host name. | native static String | getHostNameImpl() Query the IP stack for the host machine name. | static String | getHostNameInternal(String host) | public static InetAddress | getLocalHost() Answer the local host, if allowed by the security policy. | public int | hashCode() Answer a hashcode for this IP address. | static int | inetAddr(String host) | native static int | inetAddrImpl(String host) Convert a string containing an Ipv4 Internet Protocol dotted address into
a binary address. | native static String | inetNtoaImpl(int hipAddr) Convert a binary address into a string containing an Ipv4 Internet
Protocol dotted address. | static void | intToBytes(int value, byte bytes, int start) Takes the integer and chops it into 4 bytes, putting it into the byte
array starting with the high order byte at the index start. | public boolean | isAnyLocalAddress() Method isAnyLocalAddress. | public boolean | isLinkLocalAddress() Answers true if the address is a link local address. | public boolean | isLoopbackAddress() Answer true if the address is a loop back address. | public boolean | isMCGlobal() Answers true if the address is a global multicast address. | public boolean | isMCLinkLocal() Answers true if the address is a link local multicast address. | public boolean | isMCNodeLocal() Answers true if the address is a node local multicast address. | public boolean | isMCOrgLocal() Answers true if the address is a organization local multicast address. | public boolean | isMCSiteLocal() Answers true if the address is a site local multicast address. | public boolean | isMulticastAddress() Answer true if the InetAddress is an IP multicast address. | public boolean | isReachable(int timeout) Tries to see if the InetAddress is reachable. | public boolean | isReachable(NetworkInterface netif, int ttl, int timeout) Tries to see if the InetAddress is reachable. | public boolean | isSiteLocalAddress() Answers true if the address is a site local address. | static synchronized InetAddress | lookupHostByName(String host) | static boolean | preferIPv6Addresses() | public String | toString() Answers a string containing a concise, human-readable description of the
address. |
any_bytes | final static byte[] any_bytes(Code) | | |
ipaddress | byte[] ipaddress(Code) | | |
localhost_bytes | final static byte[] localhost_bytes(Code) | | |
InetAddress | InetAddress()(Code) | | Constructs an InetAddress.
|
InetAddress | InetAddress(byte[] address)(Code) | | Constructs an InetAddress, representing the address and
hostName .
Parameters: address - network address |
InetAddress | InetAddress(byte[] address, String hostName)(Code) | | Constructs an InetAddress, representing the address and
hostName .
Parameters: address - network address |
bytesToInt | static int bytesToInt(byte bytes, int start)(Code) | | Takes the byte array and creates an integer out of four bytes starting at
start as the high-order byte. This method makes no checks on the validity
of the parameters.
|
cacheElement | CacheElement cacheElement()(Code) | | |
createHostNameFromIPAddress | static InetAddress createHostNameFromIPAddress(String ipAddressString) throws UnknownHostException(Code) | | Creates an InetAddress based on an ipAddressString. No error handling is
performed here.
|
equals | public boolean equals(Object obj)(Code) | | Compares this InetAddress against the specified object.
Parameters: obj - the object to be tested for equality boolean true, if the objects are equal |
getAddress | public byte[] getAddress()(Code) | | Returns the IP address of this InetAddress as an array.
The elements are in network order (the highest order address byte is in
the zero-th element).
byte[] the address as a byte array |
getAllByName | public static InetAddress[] getAllByName(String host) throws UnknownHostException(Code) | | Answer the IP addresses of a named host. The host name may either be a
machine name or a dotted string IP address. If the host name is empty or
null, an UnknownHostException is thrown. If the host name is a dotted IP
string, an array with the corresponding single InetAddress is returned.
Parameters: host - the hostName to be resolved to an address InetAddress[] an array of addresses for the host throws: UnknownHostException - if the address lookup fails |
getByAddress | public static InetAddress getByAddress(byte[] ipAddress) throws UnknownHostException(Code) | | Answers the InetAddress corresponding to the array of bytes. In the case
of an IPv4 address there must be exactly 4 bytes and for IPv6 exactly 16
bytes. If not, an UnknownHostException is thrown.
The IP address is not validated by a name service.
The high order byte is ipAddress[0] .
Parameters: ipAddress - either a 4 (IPv4) or 16 (IPv6) byte array the InetAddress throws: UnknownHostException - |
getByAddress | static InetAddress getByAddress(byte[] ipAddress, int scope_id) throws UnknownHostException(Code) | | Answers the InetAddress corresponding to the array of bytes. In the case
of an IPv4 address there must be exactly 4 bytes and for IPv6 exactly 16
bytes. If not, an UnknownHostException is thrown.
The IP address is not validated by a name service.
The high order byte is ipAddress[0] .
Parameters: ipAddress - either a 4 (IPv4) or 16 (IPv6) byte array Parameters: scope_id - the scope id for an IPV6 scoped address. If not a scopedaddress just pass in 0 the InetAddress throws: UnknownHostException - |
getByAddress | public static InetAddress getByAddress(String hostName, byte[] ipAddress) throws UnknownHostException(Code) | | Answers the InetAddress corresponding to the array of bytes, and the
given hostname. In the case of an IPv4 address there must be exactly 4
bytes and for IPv6 exactly 16 bytes. If not, an UnknownHostException is
thrown.
The host name and IP address are not validated.
The hostname either be a machine alias or a valid IPv6 or IPv4 address
format.
The high order byte is ipAddress[0] .
Parameters: hostName - string representation of hostname or ip address Parameters: ipAddress - either a 4 (IPv4) or 16 (IPv6) byte array the InetAddress throws: UnknownHostException - |
getByAddressInternal | static InetAddress getByAddressInternal(String hostName, byte[] ipAddress, int scope_id) throws UnknownHostException(Code) | | Answers the InetAddress corresponding to the array of bytes, and the
given hostname. In the case of an IPv4 address there must be exactly 4
bytes and for IPv6 exactly 16 bytes. If not, an UnknownHostException is
thrown.
The host name and IP address are not validated.
The hostname either be a machine alias or a valid IPv6 or IPv4 address
format.
The high order byte is ipAddress[0] .
Parameters: hostName - string representation of hostname or IP address Parameters: ipAddress - either a 4 (IPv4) or 16 (IPv6) byte array Parameters: scope_id - the scope id for a scoped address. If not a scoped addressjust pass in 0 the InetAddress throws: UnknownHostException - |
getByName | public static InetAddress getByName(String host) throws UnknownHostException(Code) | | Answers the address of a host, given a host string name. The host string
may be either a machine name or a dotted string IP address. If the
latter, the hostName field will be determined upon demand.
Parameters: host - the hostName to be resolved to an address InetAddress the InetAddress representing the host throws: UnknownHostException - if the address lookup fails |
getCanonicalHostName | public String getCanonicalHostName()(Code) | | Answers canonical name for the host associated with the internet address
String string containing the host name |
getHostAddress | public String getHostAddress()(Code) | | Answer the dotted string IP address representing this address.
String the corresponding dotted string IP address |
getHostByAddrImpl | native static InetAddress getHostByAddrImpl(byte[] addr) throws UnknownHostException(Code) | | Query the IP stack for the host address. The host is in address form.
Parameters: addr - the host address to lookup throws: UnknownHostException - if an error occurs during lookup |
getHostByNameImpl | native static InetAddress getHostByNameImpl(String name, boolean preferIPv6Address) throws UnknownHostException(Code) | | Query the IP stack for the host address. The host is in string name form.
Parameters: name - the host name to lookup Parameters: preferIPv6Addresses - address preference if underlying platform is V4/V6 InetAddress the host address throws: UnknownHostException - if an error occurs during lookup |
getHostName | public String getHostName()(Code) | | Answer the host name.
String the corresponding string name |
getHostNameImpl | native static String getHostNameImpl()(Code) | | Query the IP stack for the host machine name.
String the host machine name |
getLocalHost | public static InetAddress getLocalHost() throws UnknownHostException(Code) | | Answer the local host, if allowed by the security policy. Otherwise,
answer the loopback address which allows this machine to be contacted.
InetAddress the InetAddress representing the local host throws: UnknownHostException - if the address lookup fails |
hashCode | public int hashCode()(Code) | | Answer a hashcode for this IP address.
int the hashcode |
inetAddrImpl | native static int inetAddrImpl(String host) throws UnknownHostException(Code) | | Convert a string containing an Ipv4 Internet Protocol dotted address into
a binary address. Note, the special case of '255.255.255.255' throws an
exception, so this value should not be used as an argument. See also
inetAddr(String).
|
inetNtoaImpl | native static String inetNtoaImpl(int hipAddr)(Code) | | Convert a binary address into a string containing an Ipv4 Internet
Protocol dotted address.
|
intToBytes | static void intToBytes(int value, byte bytes, int start)(Code) | | Takes the integer and chops it into 4 bytes, putting it into the byte
array starting with the high order byte at the index start. This method
makes no checks on the validity of the parameters.
|
isAnyLocalAddress | public boolean isAnyLocalAddress()(Code) | | Method isAnyLocalAddress.
boolean |
isLinkLocalAddress | public boolean isLinkLocalAddress()(Code) | | Answers true if the address is a link local address.
Valid IPv6 link local addresses are FE80::0 through to
FEBF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF
There are no valid IPv4 link local addresses.
boolean |
isLoopbackAddress | public boolean isLoopbackAddress()(Code) | | Answer true if the address is a loop back address. Valid IPv4 loopback
addresses are 127.d.d.d Valid IPv6 loopback address is ::1
boolean |
isMCGlobal | public boolean isMCGlobal()(Code) | | Answers true if the address is a global multicast address.
Valid IPv6 link global multicast addresses are FFxE:/112 where x is a set
of flags, and the additional 112 bits make up the global multicast
address space
Valid IPv4 global multicast addresses are between: 224.0.1.0 to
238.255.255.255
boolean |
isMCLinkLocal | public boolean isMCLinkLocal()(Code) | | Answers true if the address is a link local multicast address.
Valid IPv6 link local multicast addresses are FFx2:/112 where x is a set
of flags, and the additional 112 bits make up the node local multicast
address space
Valid IPv4 link-local addresses are between: 224.0.0.0 to 224.0.0.255
boolean |
isMCNodeLocal | public boolean isMCNodeLocal()(Code) | | Answers true if the address is a node local multicast address.
Valid IPv6 node local multicast addresses are FFx1:/112 where x is a set
of flags, and the additional 112 bits make up the node local multicast
address space
There are no valid IPv4 node local multicast addresses.
boolean |
isMCOrgLocal | public boolean isMCOrgLocal()(Code) | | Answers true if the address is a organization local multicast address.
Valid IPv6 organization local multicast addresses are FFx8:/112 where x
is a set of flags, and the additional 112 bits make up the node local
multicast address space
Valid IPv4 organization-local addresses are between: 239.192.0.0 to
239.251.255.255
boolean |
isMCSiteLocal | public boolean isMCSiteLocal()(Code) | | Answers true if the address is a site local multicast address.
Valid IPv6 site local multicast addresses are FFx5:/112 where x is a set
of flags, and the additional 112 bits make up the node local multicast
address space
Valid IPv4 site-local addresses are between: 239.252.0.0 to
239.255.255.255
boolean |
isMulticastAddress | public boolean isMulticastAddress()(Code) | | Answer true if the InetAddress is an IP multicast address.
boolean true, if the address is in the multicast group |
isReachable | public boolean isReachable(int timeout) throws IOException(Code) | | Tries to see if the InetAddress is reachable. This method first tries to
use ICMP(ICMP ECHO REQUEST). When first step fails, the TCP connection on
port 7 (Echo) shall be lauched.
Parameters: timeout - timeout in milliseconds true if address is reachable throws: IOException - if I/O operation meets error throws: IllegalArgumentException - if timeout is less than zero |
isReachable | public boolean isReachable(NetworkInterface netif, int ttl, int timeout) throws IOException(Code) | | Tries to see if the InetAddress is reachable. This method first tries to
use ICMP(ICMP ECHO REQUEST). When first step fails, the TCP connection on
port 7 (Echo) shall be lauched.
Parameters: netif - the network interface through which to connect Parameters: ttl - max hops to live Parameters: timeout - timeout in milliseconds true if address is reachable throws: IOException - if I/O operation meets error throws: IllegalArgumentException - if ttl or timeout is less than zero |
isSiteLocalAddress | public boolean isSiteLocalAddress()(Code) | | Answers true if the address is a site local address.
Valid IPv6 link local addresses are FEC0::0 through to
FEFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF
There are no valid IPv4 site local addresses.
boolean |
preferIPv6Addresses | static boolean preferIPv6Addresses()(Code) | | |
toString | public String toString()(Code) | | Answers a string containing a concise, human-readable description of the
address.
String the description, as host/address |
|
|