Java Network Programming

Errata for Java Network Programming

Submit your own errata for this product.


The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question Note Update



Version Location Description Submitted By Date Submitted Date Corrected
Printed
Page xvi-xvii
The following text was added to the preface

"How to Contact Us We have tested and verified the information in this book to the best of our ability, but you may find that features have changed (or even that we have made mistakes!). Please let us know about any errors you find, as well as your suggestions for future editions, by writing to: O'Reilly & Associates, Inc. 101 Morris Street Sebastopol, CA 95472 1-800-998-9938 (in the U.S. or Canada) 1-707-829-0515 (international/local) 1-707-829-0104 (FAX) You can also send us messages electronically. To be put on the mailing list or request a catalog, send email to: info@oreilly.com I enjoy hearing from readers, whether with general comments about how this could be a better book, specific corrections, or other topics you would like to see covered. You can reach me by sending email to: bookquestions@oreilly.com Please realize, however, that I receive several hundred pieces of email a day and cannot personally respond to each one. We have a web site for the book, where we'll list examples, errata, and any plans for future editions. You can access this page at: http://www.oreilly.com/catalog/9781565922273/ For more information about this book and others, see the O'Reilly web site: http://www.oreilly.com

Anonymous    Mar 01, 2000
Printed
Page 3
para. 3, line 9: "content handers" should be "content handlers"

Anonymous    Mar 01, 1998
Printed
Page 5
last para., line 3: "reaon" should be "reason"

Anonymous    Mar 01, 1998
Printed
Page 19
end of 1st para: "who to reply to." should be changed to "where

to send the reply", or at a minimum "whom to reply to" (or something similar like "to whom to reply").

Anonymous    Mar 01, 1998
Printed
Page 22
para. 3, line 3: the comma between "computers" and "connected"

should be deleted

Anonymous    Mar 01, 1998
Printed
Page 23

Changed Figure 2-3. It now reads: B 1 0 C 1 1 0 D 1 1 1 0 E 1 1 1 1 0

Anonymous    Apr 01, 1999
Printed
Page 39
next-to-last para., line 1: "keyword lets the server" should be

"keyword that lets the server"

Anonymous    Mar 01, 1998
Printed
Page 45
Table 3-2, line -6: "serve.class" now reads "serve .class"

Anonymous    Jun 01, 1999
Printed
Page 52
In step 4 deleted <P>

GET /javafaq/classes/animation.class HTTP/1.0 and the blank line that followed it.

Anonymous    Apr 01, 1999
Printed
Page 53

In the second paragraph, the text used to read: "applets loaded from the network" It now reads: "untrusted, unsigned applets loaded from the network"

Anonymous    Mar 01, 2000
Printed
Page 54
para. after list: "Of these eight" should be "Of these ten"

Anonymous    Mar 01, 1998
Printed
Page 54
"Of these eight" changed to "Of these ten"

Anonymous    Apr 01, 1999
Printed
Page 68
In the first paragraph, changed "polymorphic newInetAddressFactory()

methods." to "overloaded newInetAddressFactory() methods."

Anonymous    Apr 01, 1999
Printed
Page 68
Example 4-8: changed

// Use a byte array like {199, 1, 32, 90} to build // an InetAddressObject to // Use a byte array like {(byte) 199, (byte) 1, (byte) 32, (byte) 90} // to build an InetAddressObject

Anonymous    Apr 01, 1999
Printed
Page 70

Para. 1, line 4 used to read: "we add a polymorphic newInetAddress() method" It now reads: "we add an overloaded newInetAddress() method"

Anonymous    Apr 01, 1999
Printed
Page 71
In para. 3, line 3: "Factory" in "InetAddressFactory" is now in

constant-width font.

Anonymous    Jun 01, 1999
Printed
Page 73
1st code, line 7: "in dotted quad format" now appears within a

comment block.

Anonymous    Jun 01, 1999
Printed
Page 74
Para. -1, line -3 used to read "11:53 PM"; changed to "10:53 PM"

Anonymous    Apr 01, 1999
Printed
Page 84
2nd para., line 4: "package" is in constant-width, should be

Roman

Anonymous    Mar 01, 1998
Printed
Page 84
1st code, line 2: "thispage" should read "thisPage"

Anonymous    Mar 01, 1998
Printed
Page 85
1st code, line 2: "thispage" should read "thisPage"

Anonymous    Mar 01, 1998
Printed
Page 99

Code line 15 used to read: URL root = new URL(args[0]) It now reads URL root = new URL(args[i])

Anonymous    Jun 01, 1999
Printed
Page 99

The code line 20 used to read: System.err.println(args[0] + " is not a parseable URL") It now reads: System.err.println(args[i] + " is not a parseable URL")

Anonymous    Jun 01, 1999
Printed
Page 100
In line 21: "finally" is now in a comment.

Anonymous    Jun 01, 1999
Printed
Page 110
In code 1, line 1: the space after "paint" was deleted.

Anonymous    Apr 01, 1999
Printed
Page 113
In code 3 & 4: deleted spurious space after "("

Anonymous    Apr 01, 1999
Printed
Page 113
Para. 5, last line: added a thinspace after "logo.gif"

Anonymous    Jun 01, 1999
Printed
Page 113
There were some extra closing parentheses at the ends of the

last three code fragments. They now read: Image myImage = getImage(getCodeBase(), "logo.gif"); Image myImage = getImage( getDocumentBase(), "logo.gif"); Image myImage = getImage( getDocumentBase(), "images/logo.gif");

Anonymous    Mar 01, 2000
Printed
Page 114
The last code fragment at the bottom of the page had an extra

closing parenthesis at the end. It now reads: play(getCodeBase(), "gong.au"));

Anonymous    Mar 01, 2000
Printed
Page 115
The first two code fragments at the top of the page had

extra closing parentheses. They now read: play(getDocumentBase(), getParameter("soundfile")); play (getDocumentBase(), "sounds/gong.au");

Anonymous    Mar 01, 2000
Printed
Page 116
Para. 3, last line: "sounds" is now in italics

Anonymous    Jun 01, 1999
Printed
Page 116
The first and third code fragments on the page had extra

parentheses. They now read: getAudioClip(getCodeBase(), "gong.au"); getAudioClip (getDocumentBase(), "sounds/gong.au");

Anonymous    Mar 01, 2000
Printed
Page 130

1st line of text: "You use these constants are used" now reads: "These constants are used"

Anonymous    Jun 01, 1999
Printed
Page 130-131
The text was changed from m.statusAll to m.statusID.

These two examples used to read: "statusAll" They now read: "statusID"

Anonymous    Mar 01, 2000
Printed
Page 148

The second to last paragraph now reads: The Multihome applet redirects requests for http://www.siteA.com/somedirectory/somefile.html to requests for http://www.siteA.com/www.siteA.com/somedirectory/somefile.html, requests for http://www.siteB.com/somedirectory/somefile.html to requests for http://www.siteB.com/www.siteB.com/somedirectory/somefile.html, and so on.

Anonymous    Jun 01, 1999
Printed
Page 152
The 2nd code example used to read: "to Ora" It now reads: "toOra"

Anonymous    Apr 01, 1999
Printed
Page 155

In Example 7-3, the line used to read: theSocket = new Socket(host, i)</CODE> It now reads: theSocket = new Socket(theAddress, i)</CODE>

Anonymous    Apr 01, 1999
Printed
Page 156
In the next-to-last para.: "IOException" is now in constant-width

Anonymous    Jun 01, 1999
Printed
Page 158
1st para., line 2: "when" is in Garamond font.

Anonymous    Jun 01, 1999
Printed
Page 164

Para. 1, line 2: "You use the hostname is to create" now reads: "You use the hostname to create"

Anonymous    Jun 01, 1999
Printed
Page 166

Example 7-7 used to read: theSocket = new Socket(host, i) It now reads: theSocket = new Socket(theAddress, i)

Anonymous    Jun 01, 1999
Printed
Page 167
Para. 4, line 4: added a space between "java.net" and "package"

Anonymous    Jun 01, 1999
Printed
Page 168
Changed

if (!s.getTcpNoDelay()) s.setTcpNoDelay() to if (!s.getTcpNoDelay()) s.setTcpNoDelay(true)

Anonymous    Jun 01, 1999
Printed
Page 169

First code fragment used to read: if (s.getTcpNoLinger() != -1) ...... It now reads: s.getSoLinger

Anonymous    Jun 01, 1999
Printed
Page 169
Changed s.setSoLinger(240) to s.setSoLinger(true, 240)

Anonymous    Jun 01, 1999
Printed
Page 188

In the code fragemnt in the middle of the page used to read: "InetAddress.getHostByName("sunsite.unc.edu")" It now reads: "InetAddress.getByName("sunsite.unc.edu")"

Anonymous    Mar 01, 2000
Printed
Page 189
The comma after "can't" and "want to" should be removed in

the note at the bottom of the page.

Anonymous   
Printed
Page 193
Changed both occurrences of InterruptedException to

InterruptedIOException

Anonymous    Jun 01, 1999
Printed
Page 199
In Example 8-5, changed

static String theData; to static String theData = ""; in the first line of the class

Anonymous    Apr 01, 1999
Printed
Page 199
In Example 8-5, changed

String thisLine; to String thisLine = "";

Anonymous    Jun 01, 1999
Printed
Page 209

Changed code. It now reads: --------------cut here----------------------- public void run() { String method; String file=""; String ct; String version = ""; File theFile; try { PrintStream os = new PrintStream(theConnection.getOutputStream()); DataInputStream is = new DataInputStream(theConnection.getInputStream()); String get = is.readLine(); StringTokenizer st = new StringTokenizer(get); method = st.nextToken(); if (st.hasMoreTokens()) { file = st.nextToken(); if (file.endsWith("/")) file += indexfile; } if (st.hasMoreTokens()) version = st.nextToken(); if (method.equals("GET")) { ct = guessContentTypeFromName(file); // loop through the rest of the input lines while ((get = is.readLine()) != null) { if (get.trim().equals("")) break; } try { theFile = new File(docroot, file.substring(1,file.length())); FileInputStream fis = new FileInputStream(theFile); byte[] theData = new byte[(int) theFile.length()]; // need to check the number of bytes read here fis.read(theData); fis.close(); if (version.startsWith("HTTP/")) { // send a MIME header os.print("HTTP/1.0 200 OK "); Date now = new Date(); os.print("Date: " + now + " "); os.print("Server: jhttp 1.0 "); os.print("Content-length: " + theData.length + " "); os.print("Content-type: " + ct + " "); } // end try // send the file os.write(theData); os.close(); } // end try catch (IOException e) { // can't find the file if (version.startsWith("HTTP/")) { // send a MIME header os.print("HTTP/1.0 404 File Not Found "); Date now = new Date(); os.print("Date: " + now + " "); os.print("Server: jhttp 1.0 "); os.print("Content-type: text/html" + " "); } os.println("<HTML><HEAD><TITLE>File Not Found</TITLE></HEAD>"); os.println("<BODY><H1>HTTP Error 404: File Not Found</H1></BODY></HTML>"); os.close(); } } else { // method does not equal "GET" if (version.startsWith("HTTP/")) { // send a MIME header os.print("HTTP/1.0 501 Not Implemented "); Date now = new Date(); os.print("Date: " + now + " "); os.print("Server: jhttp 1.0 "); os.print("Content-type: text/html" + " "); } os.println("<HTML><HEAD><TITLE>Not Implemented</TITLE></HEAD>"); os.println("<BODY><H1>HTTP Error 501: Not Implemented</H1></BODY></HTML>"); os.close(); } } catch (IOException e) { } try { theConnection.close(); } catch (IOException e) { } }

Anonymous    Apr 01, 1999
Printed
Page 226
In Examples 9-7

Changed try { DatagramSocket ds = new DatagramSocket(port); DatagramPacket dp = new DatagramPacket(buffer, buffer.length); while (true) { try { to try { DatagramSocket ds = new DatagramSocket(port); while (true) { DatagramPacket dp = new DatagramPacket(buffer, buffer.length); try {

Anonymous    Apr 01, 1999
Printed
Page 226
In the code, changed to order of the lines

try{ DatagramPacket dp = new DatagramPacket(buffer, buffer.length); It now reads: DatagramPacket dp = new DatagramPacket(buffer, buffer.length); try{

Anonymous    Jun 01, 1999
Printed
Page 231
The line

"public UPDClient(InetAddress ia, int port) throws SocketException {" was aligned one space to the left.

Anonymous    Mar 01, 2000
Printed
Page 234
2nd paragraph, 1st sentence, changed "may be overridden" to

"may be accessed"

Anonymous    Jun 01, 1999
Printed
Page 234
2nd paragraph, 4th sentence, changed "Subclasses override this

field with" to "Subclasses change this field to"

Anonymous    Jun 01, 1999
Printed
Page 236
In paragraph 3, changed

"If the buffer length is not specified, 512 bytes is used." to: "If the buffer length is not specified 65,507 bytes is used."

Anonymous    Apr 01, 1999
Printed
Page 236
In Example 9-11, changed

protected static int defaultPort = 13; to static { defaultPort = 13; }

Anonymous    Jun 01, 1999
Printed
Page 236
Changed "can be overridden by subclasses" to "can be changed by

subclasses"

Anonymous    Jun 01, 1999
Printed
Page 237
Example 9-12: changed

incoming = new DatagramPacket(buffer, buffer.length); while (true) { to while (true) { incoming = new DatagramPacket(buffer, buffer.length);

Anonymous    Apr 01, 1999
Printed
Page 238
Example 9-13: changed

"protected static int defaultPort = 9;" to static { defaultPort = 13; }

Anonymous    Apr 01, 1999
Printed
Page 238
Example 9-14: changed

"protected static int defaultPort = 9;" to static { defaultPort = 13; }

Anonymous    Apr 01, 1999
Printed
Page 238
Example 9-15: changed

"protected static int defaultPort = 7;" to static { defaultPort = 7; }

Anonymous    Apr 01, 1999
Printed
Page 239
Example 9-15: changed

"protected static int defaultPort = 13;" to static { defaultPort = 13; }

Anonymous    Apr 01, 1999
Printed
Page 242
Deleted the line eot.stop(); in Example 9-18.

Anonymous    Apr 01, 1999
Printed
Page 243
Example 9-19<P>

Changed buffer = new byte[65507]; to byte[] buffer = new byte[65507];

Anonymous    Apr 01, 1999
Printed
Page 248
In para 1 (after code), line 1: "as Example 5-5" should be

"as Example 5-6".

Anonymous    Jun 01, 1999
Printed
Page 252
Changed

uc.getHeaderField("content-encoding")); to uc.getHeaderField("content-encoding"); That is, deleted the extra closing parenthesis.

Anonymous    Apr 01, 1999
Printed
Page 253
Changed "The first header is zero" to "The first MIME header is

one."

Anonymous    Apr 01, 1999
Printed
Page 276
In paragraph 3: changed

"The request above contains two name-value pairs, separated by ampersands." to "The request above contains two name-value pairs, separated by an ampersand."

Anonymous    Apr 01, 1999
Printed
Page 278
In example 10-16, deleted the line "int cl = query.length();"

Anonymous    Apr 01, 1999
Printed
Page 284
In list item number 3, changed

sun.net.www.protocol.Handler to sun.net.www.protocol.protocol.Handler

Anonymous    Apr 01, 1999
Printed
Page 284
In list item number 3, changed the first "protocol":

sun.net.www.protocol.protocol.Handler It is no longer in italics.

Anonymous    Jun 01, 1999
Printed
Page 288
In paragraph 4: changed

"This method must be overridden in each subclass of <CODE>URLConnection</CODE>." to "This method must be overridden in each subclass of <CODE>URLStreamHandler</CODE>."

Anonymous    Apr 01, 1999
Printed
Page 291
In Example 11-2 at the top of the page, changed

return text/plain; to return "text/plain;

Anonymous    Apr 01, 1999
Printed
Page 293

The text used to read: "of the createURLStreamHandlerFactory interface" It now reads: "of the URLStreamHandlerFactory interface"

Anonymous    Apr 01, 1999
Printed
Page 299
SO_LINGER code example

The code example to setSoLinger() if (s.getTcpSoLinger() == -1) s.setSoLinger(true, 240); should read: if (s.getSoLinger() == -1) s.setSoLinger(true, 240); p. 376: At the beginning of the first sentence of the last paragraph, "fSecure client sockets" should be "Secure client sockets".

Anonymous   
Printed
Page 311

{311} Example 12-2: In the test() method, deleted "String theLine;"

Anonymous    Apr 01, 1999
Printed
Page 315
Para. 3, line 5: "Image" now reads "IMAGE"

Anonymous    Jun 01, 1999
Printed
Page 330
Para. 2, line 1: "Asssigned" now reads "Assigned"

Anonymous    Jun 01, 1999
Printed
Page 336
Figure 13-3: The labels "without Multicast Sockets" and "with

Multicast Sockets" were reversed. "withMulticast Sockets" is now over the left half of the picture.

Anonymous    Jun 01, 1999
Printed
Page 343
In Example 13-3, moved the line

DatagramPacket dp = new DatagramPacket(buffer, buffer.length); Immediately after while (true) {; i.e. Now reads: while (true) { DatagramPacket dp = new DatagramPacket(buffer, buffer.length);

Anonymous    Jun 01, 1999
Printed
Page 344
In the footnote: "InetAddress Factory" now reads "InetAddressFactory"

Anonymous    Jun 01, 1999
Printed
Page 350
Table 14-1: java.awt.Image is not Serializable. Moved it from

the left hand column to the right-hand column.

Anonymous    Jun 01, 1999
Printed
Page 352
In Fig 14-1, the "Skeleton" block under the client program has been

changed to "Stub".

Anonymous    Jun 01, 1999
Printed
Page 356
In line -3: "Hello, world!" now reads "Hello, World!"

Anonymous    Jun 01, 1999
Printed
Page 359
Paragraph 4: Deleted the phrase ", just as the server did".

Anonymous    Jun 01, 1999
Printed
Page 364
Line 2: "System.setSecurityManager" changed the font on the first "S"

Anonymous    Jun 01, 1999
Printed
Page 369
The second sentence in the section "The LocateRegistry Class"

"This is achieved with four polymorphic versions the static getRegistry()method." Now reads "This is achieved with four overloaded versions of the static getRegistry() method."

Anonymous    Jun 01, 1999
Printed
Page 378
2nd bullet item, last line: "mangers" now reads "managers"

Anonymous    Jun 01, 1999
Printed
Page 380
Changed "a polymorphic version" to "an overloaded version"

Anonymous    Jun 01, 1999
Printed
Page 380
In item #6: "vresponse" now reads "response"

Anonymous    Jun 01, 1999
Printed
Page 380
Para. 3, line -3: changed the font on "service" to CW

Anonymous    Jun 01, 1999
Printed
Page 404
2nd line from the bottom: "IOEXception" now reads "IOException"

Anonymous    Jun 01, 1999
Printed
Page 404
2nd text para.: "writeErrorResponse" now reads "sendError"

Anonymous    Jun 01, 1999
Printed
Page 413
In the Index, item "getContentType", subitem

"servletRequestI interface)" - deleted parenthesis

Anonymous    Jun 01, 1999
Printed
Page 414
Item "IANA", deleted page 29 listing

Anonymous    Jun 01, 1999
Printed
Page 417
Item "opening", subitem "URLConection" now reads "URLConnection"

Anonymous    Jun 01, 1999
Printed
Page 418
Item "REGISTRY_PORT field, 368" now reads "REGISTRY_PORT field, 369"

Anonymous    Jun 01, 1999
Printed
Page 420
Item "TCP_DELAY" now reads "TCP_NODELAY"

Anonymous    Jun 01, 1999