Corrections to Chapter 7 of Java Network Programming, Sockets for Clients

p. 152: In the example at the bottom of the page "to Ora" should be one word; that is,

Socket toOra = new Socket("www.ora.com");

p. 154-155: The code fragment that starts at the bottom of p. 154 tries to use a non-existent public InetAddress constructor, and may try to use a null object to boot. It should read:

try {
  InetAddress OReilly  = InetAddress.getByName("www.oreilly.com");
  Socket OReillySocket = new Socket(OReilly, 80);
  // send and receive data...
}
catch (UnknownHostException e) {
  System.err.println(e);
}
catch (IOException e) {
  System.err.println(e);
}
p. 155: In Example 7-3 the line
 theSocket = new Socket(host, i) 
should be

theSocket = new Socket(theAddress, i)
Both are correct, but only the second makes the point I was trying to make in this example.

p. 166, Example 7-7 has the same problem.

 theSocket = new Socket(host, i) 
should be

theSocket = new Socket(theAddress, i)
p. 168: Change

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

 if (!s.getTcpNoDelay()) s.setTcpNoDelay(true)  
p. 169: Change s.setSoLinger(240) to s.setSoLinger(true, 240)


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

Copyright 1998-2000 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified Deecember 29, 2000