See Also: InetAddress Members
An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in practice you'll have an instance of either Inet4Address or Inet6Address (this class cannot be instantiated directly). Most code does not need to distinguish between the two families, and should use InetAddress.
An InetAddress may have a hostname (accessible via getHostName), but may not, depending on how the InetAddress was created.
The getAllByName method accepts IPv4 addresses in the "decimal-dotted-quad" form only:
The getAllByName method accepts IPv6 addresses in the following forms (this text comes from , which you should consult for full details of IPv6 addressing):
java Example
FEDC:BA98:7654:3210:FEDC:BA98:7654:3210 1080:0:0:0:8:800:200C:417A
java Example
1080:0:0:0:8:800:200C:417A a unicast address FF01:0:0:0:0:0:0:101 a multicast address 0:0:0:0:0:0:0:1 the loopback address 0:0:0:0:0:0:0:0 the unspecified addresses
java Example
1080::8:800:200C:417A a unicast address FF01::101 a multicast address ::1 the loopback address :: the unspecified addresses
java Example
0:0:0:0:0:0:13.1.68.3 0:0:0:0:0:FFFF:129.144.52.38
java Example
::13.1.68.3 ::FFFF:129.144.52.38
Scopes are given using a trailing % followed by the scope id, as in 1080::8:800:200C:417A%2 or 1080::8:800:200C:417A%en0. See for more on IPv6's scoped address architecture.
Additionally, for backwards compatibility, IPv6 addresses may be surrounded by square brackets.
In Android 4.0 (Ice Cream Sandwich) and earlier, DNS caching was performed both by InetAddress and by the C library, which meant that DNS TTLs could not be honored correctly. In later releases, caching is done solely by the C library and DNS TTLs are honored.