November 2006
Intermediate to advanced
224 pages
3h 29m
English
// find IP address for given domain String hostName = www.timothyfisher.com"; String ip = InetAddress.getByName(hostName).getHostAddress(); // find domain name for ip address String ipAddress = "66.43.127.5"; String hostName = InetAddres.getByName(ipAddress).getHostName(); |
In this phrase, we get a hostname when you know the IP address of a remote host, and we get an IP address when you start with the hostname of the remote host. To accomplish both of these tasks, we rely on the InetAddress class.
We use the getByName() static method of the InetAddress class to create an InetAddress instance. We can pass either an IP address or a hostname into the getByName() method to create the InetAddress instance. Once ...
Read now
Unlock full access