Corrections to Chapter 11 of Java Network Programming, Sockets for Servers

p. 354: In the code fragment at the bottom of the page, InetAddress.getHostByName("metalab.unc.edu") should be InetAddress.getByName("metalab.unc.edu"). That is,
        try {
          ServerSocket httpd = new ServerSocket(5776, 100,
           InetAddress.getByName("metalab.unc.edu"));
        }
        catch (IOException e) {
          System.err.println(e);
        }

p. 364: In the first line, jServerSocket should be ServerSocket (delete the initial j).

p. 372: In the main() method, on the last line of the page, "args.length >= 2" should be "args.length > 2".

p. 374: In the last sentence of the 1st paragraph, "However, that would raise some additional issues of thread safety that Example 11-5 doesn't have to address because it's immutable." should be "However, that would raise some additional issues of thread safety that Example 11-6 doesn't have to address because it's immutable." That is, change "11-5" to 11-6".

p. 384: In order to better handle unexpected network failures (broken sockets), near the bottom of the page change

if (c == '\r' || c == '\n') break;

to

if (c == '\r' || c == '\n' || c == -1) break;

p. 385: About three quarters of the way down the page, at the end of the second code block,

} // end try

should be

} // end if

That is, change try to if in the comment.

[ Java Network Programming Corrections | Java Network Programming Home Page | Table of Contents | Examples | Order from Amazon ] ]

Copyright 2002-2004 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified November 1, 2004