3.4. Internet Addressing with Java

By now it should be clear that a host on the Internet can be represented either in dotted decimal format as an IP address, or as a hostname such as ftp.davidreilly.com. Under Java, such addresses are represented by the java.net.InetAddress class. This class can fill a variety of tasks, from resoling an IP address to looking up the hostname. In the next section, this important class is examined in detail.

3.4.1. The java.net.InetAddress Class

The InetAddress class is used to represent IP addresses within a Java networking application. Unlike most other classes, there are no public constructors for that of InetAddress. Instead, there are two static methods that return InetAddress instances. Those and the other ...

Get Java™ Network Programming and Distributed Computing 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.