Errata

Java Network Programming

Errata for Java Network Programming, Fourth Edition

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 xx , xxi
1st paragraph ,4th paragraph

xx page, website listed as:
http://oreil.ly/java_np_eratta

xxi page websiteg listed as:
http://oreil.ly/java-network-prgamming

book listed as containing 502 pages . It contains 478 pages.

Multiple problems with the examples. Not specified what character set/character encoding is used by the examples.

Note from the Author or Editor:
Looks like someone put bit.ly links into the text and forgot to set them up. Who should fix this? I.e. establish the advertised links.

I don't think a change to the printed text is needed provided you can get the bit.ly links set up.

gary emiddio bello  Dec 20, 2013  Aug 21, 2015
PDF
Page 23
Candidate recommendation

the spec can be promoted to a candidate recommendation.

-> the spec can be promoted to a proposed recommendation.

whis is correct?

Note from the Author or Editor:
correct, p. 23 change "the spec can be promoted to a candidate recommendation" to "the spec can be promoted to a proposed recommendation"

Seong Yong, Kang  Dec 01, 2013  Aug 21, 2015
Printed
Page 155
1st paragraph

The DocBook markup shows through in the program listings and user input examples throughout Chapter 5, "URLs and URIs." See the listing on page 155 in Chapter 5 under Proxies, System Properties, for a particularly disastrous example trying to show a simple "java" command.

Other places in the chapter escape the markup characters when they shouldn't be escaped at all. For example, see the listing on page 131 showing the output of Example 5-2 that should show the HTML source of the O'Reilly home page but instead has all the HTML elements wrapped in HTML entities representing the "less than" and "great than" signs. In this case, you want to show just the actual "<" and ">" signs.

Other examples are wrong, like the carefully encoded URL on page 153 that's supposed to show the "/" character in the query string value "I/O" encoded as "I%2FO" but instead shows the un-encoded value "I/O".

It's as if nobody reviewed Chapter 5 before it went to print. There are just too many errors to submit as errata. It simply needs the review it never had.

I'm now in Chapter 7 and still finding errors, like the listing of "getContentLengthLong()" on page 193 that returns a ... an int? It should be:

public long getContentLengthLong() // Java 7

But it shows the method returning an int. I'm losing faith in an otherwise excellently written book!

Note from the Author or Editor:
Yes, and ick. On p. 155 can you check the DocBook markup? Something's gone wonky here in the first and third code fragments.

on p. 131 the &lt; should all be < and the &gt; should all be >

at the top of p. 153 in the first code fragment "I/O" should be "I%2FO"

on p. 193 change

public int getContentLengthLong

to

public long getContentLengthLong


If necessary I can check the files in Atlas, though it may take me a little while. Let me know if you want me to do that. However the problem may come in the conversion from asciidoc to DocBook later in the process.

Anonymous  Feb 26, 2014  Aug 21, 2015
Printed
Page 293
Example 9-5

Example 9-5 (pp 293) is identical to Example 11-5 (pp 370). This is the EchoServer.java example.

The problem is that the code in example 9-6 is far too advanced for the chapter, containing buffers, compacting buffers, etc. but without any explanation of the code (because it's in chapter 11).

Either there should be a more basic EchoServer.java example for chapter 9, or else in-text explanation that it's using advanced features to be found in chapter 11.

I would prefer a simpler example more appropriate to the chapter material.

Note from the Author or Editor:
Looks like the wrong EchoServer class got included here. Example 9-5 should be:

import java.net.*;
import java.io.*;
import java.util.concurrent.*;

public class EchoServer {

public final static int PORT = 7;

public static void main(String[] args) {

ExecutorService pool = Executors.newFixedThreadPool(500);

try (ServerSocket server = new ServerSocket(PORT)) {
while (true) {
try {
Socket connection = server.accept();
Callable<Void> task = new EchoTask(connection);
pool.submit(task);
} catch (IOException ex) {}
}
} catch (IOException ex) {
System.err.println("Couldn't start server");
}
}

private static class EchoTask implements Callable<Void> {

private Socket connection;

EchoTask(Socket connection) {
this.connection = connection;
}

@Override
public Void call() throws IOException {
try {
InputStream in = new BufferedInputStream(connection.getInputStream());
OutputStream out = connection.getOutputStream();
int c;
while ((c = in.read()) != -1) {
out.write(c);
out.flush();
}
} catch (IOException ex) {
System.err.println(ex);
} finally {
connection.close();
}
return null;
}
}
}





Anonymous  Jan 23, 2014  Aug 21, 2015
9999
4th

Note: since I am reading the online book, I ascribe a page number of 9999.

The error is in Chapter 1 of Safari Books Online, under the section entitled "The Internet", in the paragraph whose heading is "Internet Address Blocks".

The sentence with the problem is this one:

"However, the lowest address in all block used to identify the network itself, and the largest address is a broadcast address for the network, so you have two fewer available addresses than you might first expect."

... the error is in the first clause of the sentence - it makes no sense as written.

Note from the Author or Editor:
Change "However, the lowest address in all block used to identify the network itself, and the largest address is a broadcast address for the network," to "However, the lowest address in a block is used to identify the network itself, and the largest address in a block is a broadcast address for the network,"

pob  May 14, 2014  Aug 21, 2015
9999
Note paragraph at very end of page


The sentence that is in error says:

"So far, JavaMail Transport objects are only exceptions I�ve encountered."

This should be

"So far, JavaMail Transport objects are [the] only exceptions I�ve encountered."

Note from the Author or Editor:
p. 31 change " are only exceptions" to " are the only exceptions"

pob  May 14, 2014  Aug 21, 2015
9999
Paragraph 6: the "ALTERNATIVES TO THREADING" box

First page of Chapter 3: Threads

The sentence at fault is:

"Given the high performance of threads in modern virtual machines and operating systems, as well as the relative simplicity of a building a thread-based server, a thread-based design is usually where you should start until you can prove you�re hitting a wall."

The corrected sentence should remove the [a] below:

"Given the high performance of threads in modern virtual machines and operating systems, as well as the relative simplicity of [a] building a thread-based server, a thread-based design is usually where you should start until you can prove you�re hitting a wall."

Note from the Author or Editor:
Correct. Change "of a building a thread-based server" to "of building a thread-based server"

pob  May 14, 2014  Aug 21, 2015
9999
2nd last paragraph in the page

Chapter 3. Threads

Synchronization section

The problem is with the following sentence:

"In order for this to work, you must henceforth use only the view returned by Collections.synchronizedSet/List/Map."


This should be:

"In order for this to work, you must [subsequently] use only the view returned by Collections.synchronizedSet/List/Map."


*****

It is not my intention to make suggestions regarding the bulk of the writing style in any textbook, as style is so subjective.

However, "henceforth" means "from this time forward", whereas "subsequently" means "the time after a given event as occurred...", and so has the correct meaning.

"henceforth" is simply incorrect.

Note from the Author or Editor:
Picky, but OK. Just delete the word "henceforth" on p. 76. It's pretentious anyway.

pob  May 15, 2014  Aug 21, 2015
9999
Paragraph 1 of the sub-section

Chapter 4: Internet Addresses

Section: The InetAddress Class

Sub-section: Lookups by IP address

The following sentence has the error:

"A DNS lookup for the actual hostname is only performed when the hostname is requested, either explicitly via a getHostName()."


Words have been dropped from the sentence, and the "either" should be qualified by a subsequent pair of options, or removed altogether.

Note from the Author or Editor:
change "either explicitly via a getHostName()" to "either explicitly via getHostName() or implicitly by toString()"

pob  May 16, 2014  Aug 21, 2015
9999
Code Listing 4.8

In the 4.8 listing, we see the following pair of lines:

Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetwork
Interfaces();


Even when the font-size is decreased so that the following could easily be viewed on a single line

Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();


the listing remains broken.

Note from the Author or Editor:
on p. 109 Example 4-8 please break the line before the period in NetworkInterface.getNetworkInterfaces() rather than between Network and Interfaces

pob  May 17, 2014  Aug 21, 2015
9999
Example 5-3 Download an object

Chapter 5: URLs and URIs

Section: The URL Class

Sub-section: public final Object getContent() throws IOException


The text following the Example 5-3 says the following:

% java ContentGetter http://www.oreilly.com/ I got a
sun.net.www.protocol.http.HttpURLConnection$HttpInputStream</programlisting>

and this should be

% java ContentGetter http://www.oreilly.com/
I got a sun.net.www.protocol.http.HttpURLConnection$HttpInputStream</programlisting>

Note from the Author or Editor:
Yes, and ick. On p. 134 in the first two code fragments can you check the DocBook markup? Something's gone wonky here in the middle of the page.

If necessary I can check the files in Atlas, though it may take me a little while. Let me know if you want me to do that. However the problem may come in the conversion from asciidoc to DocBook later in the process.

pob  May 17, 2014  Aug 21, 2015
9999
Example 5-5. Are http://www.ibiblio.org and http://ibiblio.org the same?

Chapter 5: URLs and URIs

Section: The URL Class

Sub-section: Equality and Comparison

Viewing these pages in FF 29.0, I see from time to time formatting errors, such that the string "</programlisting>" turns up on pages from time to time (and variants of this string also.)

The following example is a blatant example of a formatting problem:

<programlisting format="linespecific" id="I_7_tt233">% <userinput moreinfo=
"none">
java URLEquality</userinput>
http://www.ibiblio.org/ is the same as http://ibiblio.org/</programlisting>


All that we need to see here is:

% java URLEquality
http://ibiblio.org/ is the same as http://www.ibiblio.org/



Note from the Author or Editor:
Yes, and ick. On p. 140 can you check the DocBook markup? Something's gone wonky here in the middle of the page.

If necessary I can check the files in Atlas, though it may take me a little while. Let me know if you want me to do that. However the problem may come in the conversion from asciidoc to DocBook later in the process.

pob  May 17, 2014  Aug 21, 2015
9999
Paragraph 4: Resolving Relative URIs

Chapter 5: URLs and URIs

Section: The URI Class

Sub-section: Resolving Relative URIs

The error is very minor; instead of "three" in the next line, it should be "two"

For example, take these three statements:

URI top = new URI("javafaq/books/");
URI resolved = top.resolve("jnp3/examples/07/index.html");


It should look like this:

For example, take these [two] statements:

URI top = new URI("javafaq/books/");
URI resolved = top.resolve("jnp3/examples/07/index.html");



Note from the Author or Editor:
Change "For example, take these three statements:" to "For example, take these two statements:" on p. 148

pob  May 17, 2014  Aug 21, 2015
9999
Example 5-10. Do an Open Directory search

Chapter 5: URLs and URIs

Section: Communicating with Server-Side Programs Through GET

Sub-section: N/A

In the code for Example 5-10, the following works, but does not agree with the way the dmoz site itself is set up to work:

URL u = new URL("http://www.dmoz.org/search/q?" + query)

This results in URLs like:

http://www.dmoz.org/search/q?q=java


Instead, I would expect the following:

URL u = new URL("http://www.dmoz.org/search?" + query)

so that the code would generate URLs like this:

http://www.dmoz.org/search?q=java

Note from the Author or Editor:
This is correct. Change

URL u = new URL("http://www.dmoz.org/search/q?" + query)

to

URL u = new URL("http://www.dmoz.org/search/?" + query)

as suggested

pob  May 17, 2014  Aug 21, 2015