See Also: InetAddress
public class InetAddress : Object, ISerializable, IDisposable
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.
IPv4 numeric address formats
The getAllByName method accepts IPv4 addresses in the "decimal-dotted-quad" form only:
- "18.104.22.168" - 22.214.171.124
IPv6 numeric address formats
The getAllByName method accepts IPv6 addresses in the following forms (this text comes from , which you should consult for full details of IPv6 addressing):
- The preferred form is x:x:x:x:x:x:x:x, where the 'x's are the
hexadecimal values of the eight 16-bit pieces of the address.
Note that it is not necessary to write the leading zeros in an
individual field, but there must be at least one numeral in every
field (except for the case described in the next bullet).
- Due to some methods of allocating certain styles of IPv6
addresses, it will be common for addresses to contain long strings
of zero bits. In order to make writing addresses containing zero
bits easier a special syntax is available to compress the zeros.
The use of "::" indicates multiple groups of 16-bits of zeros.
The "::" can only appear once in an address. The "::" can also be
used to compress the leading and/or trailing zeros in an address.
For example the following addresses:
may be represented as:
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
1080::8:800:200C:417A a unicast address FF01::101 a multicast address ::1 the loopback address :: the unspecified addresses
- An alternative form that is sometimes more convenient when dealing
with a mixed environment of IPv4 and IPv6 nodes is
x:x:x:x:x:x:d.d.d.d, where the 'x's are the hexadecimal values of
the six high-order 16-bit pieces of the address, and the 'd's are
the decimal values of the four low-order 8-bit pieces of the
address (standard IPv4 representation). Examples:
or in compressed form:
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.
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1
The members of Java.Net.InetAddress are listed below.
See Also: Object
|[read-only]||CanonicalHostName||String. Returns the fully qualified hostname corresponding to this IP address.|
|[read-only]||HostAddress||String. Returns the numeric representation of this IP address (such as "127.|
|[read-only]||HostName||String. Returns the host name corresponding to this IP address.|
|[read-only]||IsAnyLocalAddress||Boolean. Returns whether this is the IPv6 unspecified wildcard address :: or the IPv4 "any" address, 0.0.0.0.|
|[read-only]||IsLinkLocalAddress||Boolean. Returns whether this address is a link-local address or not.|
|[read-only]||IsLoopbackAddress||Boolean. Returns whether this address is a loopback address or not.|
|[read-only]||IsMCGlobal||Boolean. Returns whether this address is a global multicast address or not.|
|[read-only]||IsMCLinkLocal||Boolean. Returns whether this address is a link-local multicast address or not.|
|[read-only]||IsMCNodeLocal||Boolean. Returns whether this address is a node-local multicast address or not.|
|[read-only]||IsMCOrgLocal||Boolean. Returns whether this address is a organization-local multicast address or not.|
|[read-only]||IsMCSiteLocal||Boolean. Returns whether this address is a site-local multicast address or not.|
|[read-only]||IsMulticastAddress||Boolean. Returns whether this address is a multicast address or not.|
|[read-only]||IsSiteLocalAddress||Boolean. Returns whether this address is a site-local address or not.|
|LocalHost||InetAddress. Returns an InetAddress for the local host if possible, or the loopback address otherwise.|
|LoopbackAddress||InetAddress. Returns the IPv6 loopback address ::1 or the IPv4 loopback address 127.0.0.1.|
Returns the IP address represented by this InetAddress instance as a byte array.
Gets all IP addresses associated with the given host identified by name or literal IP address.
Equivalent to getByAddress(null, ipAddress).
Returns an InetAddress corresponding to the given network-order bytes ipAddress and scopeId.
Returns the address of a host according to the given host string name host.
Tries to reach this InetAddress.
|IsReachable(NetworkInterface, Int32, Int32)|
Tries to reach this InetAddress.