Tag Archives: tcp/ip

InetAddress, InetSocketAddress and multiple IP addresses assignment to a single host

InetAddress: This address maps to a single IP address for a host name even though the host name might resolve to multiple IP addresses.

One way of creating an InetAddress:

Here the “host” argument can be either a string representation of the IP Address (as in “x.x.x.x.” for IPv4) or a host name. If it is an IP Address then an InetAddress instance is returned with that IP. In such cases, the InetAddress instance would be bound to the IP specified in the host. If that host has multiple IP addresses then this InetAddress instance would remain bound to the IP address passed in. That returned instance could be an instance of the two subclasses of InetAddress for IPv4 and IPv6.

=> This constructor, if passed an IP address would invoke the InetAddress.getByName(String host) with the IP address and there would not be any reverse lookups.