This book begins with three chapters that outline how networks and network programs work. Chapter 1, is a gentle introduction to network programming in Java and the applications that it makes possible. All readers should find something of interest in this chapter. It explores some of the unique programs that become feasible when networking is combined with Java. Chapter 2, and Chapter 3, explain in detail what a programmer needs to know about how the Internet and the Web work. Chapter 2 describes the protocols that underlie the Internet, such as TCP/IP and UDP/IP. Chapter 3 describes the standards that underlie the Web such, as HTTP, HTML, and CGI. If you’ve done a lot of network programming in other languages on other platforms, you may be able to skip these two chapters.
The next two chapters throw some light on two parts of Java that are
critical to almost all network programs but are often misunderstood
and misused: I/O and threading. Chapter 4 explores
Java’s unique way of handling input and output. Understanding
how Java handles I/O in the general case is a prerequisite for
understanding the special case of how Java handles network I/O. Chapter 5 explores multithreading and synchronization,
with a special emphasis on how they can be used for asynchronous I/O
and network servers. Experienced Java programmers may be able to skim
or skip these two chapters. However, Chapter 6, is
essential reading for everyone. It shows how Java programs interact
with the Domain Name System through the
InetAddress
class, the one class that’s
needed by essentially all network programs. Once you’ve
finished this chapter, it’s possible to jump around in the book
as your interests and needs dictate. There are, however, some
interdependencies between specific chapters. Figure 0.1 should allow you to map out possible paths
through the book.
Chapter 7, explores Java’s
URL
class, a powerful abstraction for downloading
information and files from network servers of many kinds. The
URL
class enables you to connect to and download
files and documents from a network server without concerning yourself
with the details of the protocol that the server speaks. It lets you
connect to an FTP server using the same code you use to talk to an
HTTP server or to read a file on the local hard disk.
Once you’ve retrieved an HTML file from a server, you’re going to want to do something with it. Parsing and rendering HTML is one of the most difficult challenges network programmers face. Indeed, the Mozilla project has been struggling with that exact problem for more than two years. Chapter 8, introduces some little-known classes for parsing and rendering HTML documents that take this burden off your shoulders and put it on Sun’s.
Chapter 9, investigates the network methods of one
the first classes every Java programmer learns about,
Applet
. You’ll see how to load images and
audio files from network servers and track their progress. Without
using undocumented classes, this is the only way to handle audio in
Java 1.2 and earlier.
Chapter 10 through Chapter 14 discuss Java’s low-level socket classes
for network access. Chapter 10, introduces the Java
sockets API and the Socket
class in particular. It
shows you how to write network clients that interact with TCP servers
of all kinds, including whois, finger, and HTTP. Chapter 11, shows you how to use the
ServerSocket
class to write servers for these and
other protocols in Java. Chapter 12, shows you how
to protect your client/server communications using the Secure Sockets
Layer (SSL) and the Java Secure Sockets Extension ( JSSE). Chapter 13, introduces the User Datagram Protocol (UDP)
and the associated classes DatagramPacket
and
DatagramSocket
for fast, reliable communication.
Finally, Chapter 14, shows you how to use UDP to
communicate with multiple hosts at the same time. All the other
classes that access the network from Java rely on the classes
described in these five chapters.
Chapter 15 through Chapter 17 look more deeply at the infrastructure
supporting the URL
class. These chapters introduce
protocol and content handlers, concepts unique to Java that make it
possible to write dynamically-extensible software that automatically
understands new protocols and media types. Chapter 15, describes the
URLConnection
class that serves as the engine for
the URL
class of Chapter 7. It
shows you how to take advantage of this class through its public API.
Chapter 16, also focuses on the
URLConnection
class but from a different
direction; it shows you how to subclass this class to create handlers
for new protocols and URLs. Finally, Chapter 17
explores Java’s somewhat moribund mechanism for supporting new
media types.
Chapter 18 and Chapter 19 introduce two unique higher-level APIs for network programs, Remote Method Invocation (RMI) and the JavaMail API. Chapter 18, introduces this powerful mechanism for writing distributed Java applications that run across multiple heterogeneous systems at the same time while communicating with straightforward method calls just like a nondistributed program. Chapter 19, acquaints you with this standard extension to Java that offers an alternative to low-level sockets for talking to SMTP, POP, IMAP, and other email servers. Both of these APIs provide distributed applications with less cumbersome alternatives to lower-level protocols.
3.17.79.60