Java Network Programming, 1st Edition

[ Table of Contents | Examples | Index | Corrections | French translation | Japanese translation | Italian translation | Order ]

After two long years of writing, the second edition of Java Network Programming is now available. I'm keeping these pages here for readers who've already purchased the first edition. However, I recommend that you upgrade to the second edition when you get a chance. It's much more up-to-date and much more comprehensive. The web site for the second edition can be found at

Book Cover, Gyroscope
Most of what is new and exciting about Java centers around the potential for new kinds of dynamic, networked applications, and O'Reilly's Java Network Programming shows you how to write them. Topics covered include sockets, URLs, InetAddresses, UDP, TCP/IP, CGI, multicasting, applets, servlets, RMI, and more.

Manning Publications has also recently published a book titled Java Network Programming. It's not a bad book, and is surprisingly orthogonal to mine. About 2/3 of that book is streams and encryption which I only touch on. My book covers servlets, applets, multicast sockets, and Java 1.1 which that book only touches on. The matching titles appear to be just unlucky choices. Both publishers went with the most obvious title they could think of. However the cover of the Manning book has a big fish, and looks suspiciously like an O'Reilly book. Don't be fooled. The real O'Reilly book has a gyroscope or a chameleon on the cover. (The first few printings have the gyroscope. Later printings have the chameleon, and a few minor corrections but no major changes.)

If I've succeeded in piqueing your interest, you should be able to find Java Network Programming at almost any bookstore that carries computer books including the online bookstore, or Computer Literacy.

If you need to special order it, the ISBN number is 1565922271. It's $34.95, published by O'Reilly, and written by me, Elliotte Rusty Harold.

Table of Contents

Preface ix
Chapter 1 Why Networked Java? 1
What Can a Network Program Do? 2
But Wait. There's More! 11
Chapter 2 Basic Network Concepts 12
Network 12
IP, TCP, and UDP 17
The Internet 21
The Client-Server Model 25
Internet Standards: RFCs 27
Chapter 3 Basic Web Concepts 33
URLs, URIs, and URNs 34
HTML and SGML 36
CGI 48
Applets and Security 51
Chapter 4 Processing Internet Addresses 56
DNS, IP Addresses, and All That 56
The InetAddress Class 57
Converting IP Addresses to Names 67
Some Useful Programs 71
Chapter 5 Retrieving Data with URLs 78
The URL Class 78
The URLEncoder Class 94
Some Useful Programs 97
Chapter 6 The Network Methods of java.applet.Applet 109
Using the Applet Class to Download Data 109
The ImageObserver Interface 117
The MediaTracker Class 122
The Network Methods of the AppletContext Interface 131
Some Useful Programs 134
Chapter 7 Sockets for Clients 149
What Is a Socket? 149
The Socket Class 152
Socket Exceptions 169
Some Useful Programs 170
Chapter 8 Sockets for Servers 184
What Is a Server Socket? 184
The ServerSocket Class 185
Some Useful Servers 195
Chapter 9 UDP Datagrams and Sockets 212
What Is a UDP Datagram? 212
The DatagramPacket Class 214
The DatagramSocket Class 221
A Higher Level of Abstraction 230
Some Useful Applications 233
Chapter 10 The URLConnection Class 244
The URLConnection Class 244
Some Useful Programs 267
Chapter 11 Protocol Handlers 281
What Is a Protocol Handler? 281
Writing a URLStreamHandler 285
Writing a Protocol Handler 289
Factories for URLStreamHandlers 292
More Protocol Handler Examples\& and Techniques 297
Chapter 12 Content Handlers 303
What Is a Content Handler? 303
The ContentHandler Class 306
Factories for ContentHandlers 309
Some More Content Handlers 312
Chapter 13 Multicast Sockets 325
What Is a Multicast Socket? 325
Working with Multicast Sockets 337
Two Simple Examples 342
Chapter 14 Remote Method Invocation 347
What Is Remote Method Invocation? 347
Implementation 354
The java.rmi Package 360
The java.rmi.registry Package 368
The java.rmi.server Package 370
Chapter 15 The Java Server API and Servlets 375
What Is the Java Server API? 375
Writing Servlets 379
The java.servlet Package 385
The java.servlet.http Package 393
Index 409

[ Cafe au Lait | Examples | Corrections | Index | Order ]

Copyright 1996-1998, 2000 Elliotte Rusty Harold
Last Modified August 30, 2000