Chapter 13. Network Programming
The network is the soul of Java. Most of what is interesting about
Java centers on the potential for dynamic, networked applications. As Java’s
networking APIs have matured, Java has also become the language of choice
for implementing traditional client/server applications and services. In
this chapter, we start our discussion of the java.net package, which contains the fundamental
classes for communications and working with networked resources (we’ll
finish this discussion in Chapter 14). This
chapter next discusses the java.rmi package, which
provides Java’s native, high-level, Remote Method Invocation (RMI)
facilities. Finally, building on the material in Chapter 12, we complete our discussion of the java.nio package, which is highly efficient for
implementing large servers.
The classes of java.net fall into
two general categories: the Sockets API for working with low-level Internet
protocols and higher-level, web-oriented APIs that work with uniform
resource locators (URLs). Figure 13-1 shows
the java.net package.
Java’s Sockets API provides access to the standard network protocols used for communications between hosts on the Internet. Sockets are the mechanism underlying all other kinds of portable networked communications. Sockets are the lowest-level tool in the general networking toolbox—you can use sockets for any kind of communications between client and server or peer applications on the Net, but you have to implement your own application-level ...