Obtaining Hostname and IP Address Information

Often when dealing with network applications, it's necessary to figure out the IP address of some remote host. The InetAddress class represents an Internet Protocol (IP) address.

The InetAddress class contains an Internet host address. Internet hosts are identified one of two ways:

  • Name

  • Address

We have already discussed how a name is associated with an IP address back in the section "TCP/IP Architecture."

As a refresher, when you make a connection to http://www.javasoft.com, your system needs to find out the numeric address for JavaSoft. It will use a service called Domain Name Service, or DNS.

You might have noticed that Internet host names are usually a number of names that are separated by periods. ...

Get Special Edition Using Java 2 Standard Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.