The following changes will make Java Network Programming JDK 1.3 compliant: ** NB: In the text below, |buffer| means buffer in courier font. /buffer/ means bufer in italic font. [JDK1.2] means this subsection needs our JDK 1.2 tag. [JDK1.3] means this subsection needs a new JDK 1.3 tag. B.15 Permission objects ======================= Third-last paragraph fix: ------------------------- /read, /write, /execute, /delete should be read, write, execute, delete, each in italics. Second-last paragraph fix: -------------------------- /file should be file, but not in italics. 20.1 Class DatagramPacket ========================= 20.1.1 Constructors =================== Append after the first constructor: ----------------------------------- [JDK 1.2] DatagramPacket(byte buffer[], int offset, int length) This constructor is used for receiving datagrams. The |buffer| parameter is a byte array into which the received datagram will be read; |offset| is the offset within this buffer at which the packet will be stored, and |length| is the maximum number of bytes to read. Append after the last constructor: ---------------------------------- [JDK 1.2] DatagramPacket(byte buffer[], int offset, int length, InetAddress address, int port) This constructor is used to create a datagram packet for transmission. The packet body consists of |length| bytes from the byte array |buffer|, starting from offset |offset|. The packet will be delivered to the specified port |port| on the specified host |host|. 20.1.2 Methods ============== Insert before int getLength() ----------------------------- [JDK 1.2] int getOffset() This method is used to find the offset in the buffer at which the UDP packet was received. This is the value specified in the constructor. Insert after void setData() --------------------------- [JDK 1.2] void setData(byte[] data, int offset, int length) This method changes the payload of this |DatagramPacket| to the specified subarray. 20.2 DatagramSocket =================== append new subsection --------------------- 20.2.5[JDK1.3] DatagramSocket implementation As with the |Socket| class, |DatagramSocket| is actually an intermediary between network applications and a |DatagramSocketImpl| class that provides the actual implementation of network access. In some cases, for example to cope with proprietary firewall protocols, it may be useful to replace the |DatagramSocket| implementation. The following steps should be followed to do this: * Create a subclass of |DatagramSocketImpl| that implements the necessary network access methods. * Create a |DatagramSocketImplFactory| that returns instances of this new |DatagramSocketImpl| class. * Register this |DatagramSocketImplFactory| with the |DatagramSocket| class through its |setDatagramSocketImplFactory()| method. This will override the implementation of all future datagram and multicast sockets in the JVM, so this feature is controlled by the |SecurityManager|. Also, a socket implementation typically requires access to native code so this is a fairly cumbersome solution. We will not discuss it further in this book. 13.9.3 Class MyDatagramPacket ============================= Replace the code line "private int length, port;" ------------------------------------------------- private int offset, length, port; Insert before the code line "length = packet.getLength ();" ----------------------------------------------------------- offset = packet.getOffset (); Replace the code line "return new DatagramPacket..." ---------------------------------------------------- return new DatagramPacket (data, offset, length, address, port); FIGURE 13.12 ============ Both instances of "data, length, port, addr" must be replaced with "data, off, len, port, addr". 22.3 Class MulticastSocket ========================== 22.3.2 Methods ============== void setInterface() ------------------- Change "for multicast packets sent through this socket; this is useful for multihomed hosts." to "for all operations on this socket; this is useful for multihomed hosts. Under earlier versions of the JDK, this operation applied only to packets sent through this socket." Chapter 19, page 401 ==================== 19.1 Overview and 19.2 Class URL are on the same line. Contents and layout, page xxxi ============================== Change the JDK 1.1 line to: --------------------------- JDK 1.1: JDK 1.1.8 Replace the JDK 1.2 line with: ------------------------------ JDK 1.2: Java 2 SDK version 1.2.2 Insert before the JDK 1.2 line: ------------------------------- JDK 1.3: Java 2 SDK version 1.3 beta TABLE B.3 page 778 ================== Insert before Cp933: -------------------- Cp932 Japaneses Shift-JIS TABLE B.7 page 782 ================== Insert after Cp942 ------------------ Cp942C cp942c Insert after Cp943 ------------------ Cp943C cp943c Insert after Cp949 ------------------ Cp949C cp949c TABLE B.7 page 783 ================== Append to EUC_JP entry ---------------------- , x-euc-jp Append to SJIS entry -------------------- , x-sjis 13.2 Class ObjectOutputStream ============================= 13.2.2 Methods ============== Append to 13.2.2 ---------------- [JDK1.3] protected void annotateProxyClass(Class cl) throws IOException This method can be overridden to write additional information relevant to the specified proxy class |cl|. Proxy classes are a new feature of the Java 2 SDK v1.3 reflection API that support dynamic implementation of a set of interfaces specified at runtime. [JDK1.3] protected void writeClassDescriptor(ObjectStreamClass cl) throws IOException This method can be overridden by a subclass that wishes to replace the default encoding of a class descriptor. 13.3 Class ObjectInputStream ============================ 13.3.2 Methods ============== page 221, 3rd last paragraph ---------------------------- Replace "a Class object" with "an object". Append to 13.3.2 ---------------- [JDK1.3] protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException This method should be implemented by subclasses that wish to replace the default encoding of class descriptors. [JDK1.3] protected Class resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException This method reads any additional relevant information encoded in this stream and resolves a proxy class that implements the specified set of interfaces. 14.3.2 Class Socket / Methods ============================= page 259, first paragraph ------------------------- remove the last sentence (No facility ... shutdown.) page 259, before InetAddress getInetAddress() --------------------------------------------- [JDK1.3] void shutdownOutput() throws SocketException This method performs a partial shutdown on this socket, closing the output stream of communications. Any further writes on this socket will fail with an error. The remote application with which you are communicating will receive an EOF on its input stream to signal this partial shutdown, however it can still send data back to you. This is commonly used to delineate the end of a request or the end of a session. For example, a Web browser might send a request to a Web server and then shut down its output stream. The Web server will read the request, send a response, and then read EOF if it attempts to read another request. It then knows that the connection has finished, and can close the connection down. This tends to be more graceful and efficient than if the server must wait for the client to receive the entire response and then close the connection. Note that shutting down a socket; even shutting down both the input and output streams, is not equivalent to closing the socket: you must still close the socket when you are finished. Also, note that closing a socket's input or output stream is /not/ equivalent to performing a partial shutdown; doing so will close the socket completely. [JDK1.3] void shutdownInput() throws SocketException This method performs a partial shutdown on this socket, closing the input stream of communications. This means that you can no longer read from the socket; any attempt to do so will return EOF. If the application that you are communicating with attempts to write more data to the stream, it will receive an error. Use this to delineate when you have finished reading a request. For example, a HTTP/1.0 Web server might shut down its input stream after reading a client's request. This is not so often of use as the previous method. This is not equivalent to closing the socket. page 260, setSoLinger(), change first sentence ---------------------------------------------- ... linger time-out, in seconds, limit 65535, on a TCP socket. page 260, after int getReceiveBufferSize() ------------------------------------------ [JDK1.3] void setKeepAlive(boolean on) throws SocketException This method enables or disables TCP keepalive (|SO_KEEPALIVE|) on this socket. Keepalive is a feature whereby TCP periodically sends packets across the connection to make sure that a silent connection is not a dead connection. This means that an application which is blocking on reading from a socket may be eventually notified if the network silently breaks. However, you should be warned that the keepalive probe may, by default, not be sent until two hours of silence has elapsed. [JDK1.3] boolean getKeepAlive() throws SocketException This method returns whether TCP keepalive is enabled on this socket or not. Table 19.4 page 417 =================== Before HTTP_INTERNAL_ERROR put ------------------------------ HTTP_NOT_IMPLEMENTED (JDK 1.3) 501 19.2.2 Class URL / Methods ========================== page 404 before String getHost() -------------------------------- [JDK1.3] public String getAuthority() This method returns the /authority/ part of the |URL|. This is the hostname and any user authentication information, if specified. For example, the authority part of the URL http://merlin:password@nitric.com/internal/ is merlin:password@nitric.com. Consult RFC 2396 for full details of general Uniform Resource Identifier encoding. [JDK1.3] public String getUserInfo() This method returns the /user info/ part of the |URL|. This is the user authentication information, if specified. In the case of the previous example, this would be merlin:secret. The precise definition and use of the user-information part of an URL is protocol-specific. Normally, it is all text up to, but not including, the /@/ character, if present. and append to the getHost() description: ---------------------------------------- In the case of the previous example, this would be just nitric.com. page 405 append to String getFile() ----------------------------------- This is all information following the /authority/ part, but not including the anchor (reference) part. [JDK1.3] String getPath() This method returns the /path/ part of the |URL|. For example, in the URL http://nitric.com/servlet/Finger?user=merlin, the path is /servlet/Finger. The precise definition of the path part of an URL is protocol-specific, however normally it is all text in the file part; up to, but not including, the /?/ character, if present. [JDK1.3] String getQuery() This method returns the /query/ part of the |URL|. In the case of the previous example, this would be user=merlin. The precise definition of the query part of an URL is protocol-specific, however normally it is all text in the file part following the /?/ character, if present, but not including the anchor. change getRef() --------------- Change "the reference part" to "the anchor (reference) part". page 406, insert before protected void set(...) ----------------------------------------------- [JDK1.3] Object getContent(Class[] classes) throws IOException This method returns the contents of this |URL| encoded as an instance of one the specified classes (in order of preference), or |null| if none of the classes is supported. Using this mechanism, the caller has some control of how network content is encoded. For example, the URL framework might support the encoding of a HTML Web page as either a |String|, a |HTML| object or an |InputStream|. The caller can specify |String.class| if they desire the object encoded as a string, |InputStream.class| if they desire it as a stream, etc. This will only be useful, of course, if the current framework supports different encodings of its content. Class[] classes = { Reader.class, InputStream.class }; Object content = url.getContent (classes); // content will be a Reader, an InputStream or null append to protected void set(...) --------------------------------- Normally |URL|s are constant; this method can only used by specialized implementations that support alternative URL encodings, as we will discuss later in this chapter. [JDK1.3] protected void set(String protocol, String host, int port, String authority, String userInfo, String path, String query, String ref) This protected method allows a |URL| subclass to change the values of all the URL fields. 19.4.2 Class URLConneciton / Methods ==================================== page 410, after Object getContent() ----------------------------------- [JDK1.3] Object getContent(Class[] classes) throws IOException This method returns the contents of this |URLConnection| encoded as an instance of one the specified classes (in order of preference), or |null| if none of the classes is supported. Using this mechanism, the caller has some control of how network content is encoded. A JDK 1.3 content handler has the option of supporting this method to allow different encodings of network content to be supported. 19.8.1 Class URLStreamHandler / Methods ======================================= append to this subsection ------------------------- [JDK1.3] protected void setURL(URL url, String protocol, String host, int port, String authority, String userInfo, String path, String query, String ref) This utility method sets all of the fields of the specified URL to the selected values. This method should only be used by a protocol that uses a nonstandard textual URL encoding. [JDK1.3] protected int getDefaultPort() This method should return the default port used by this protocol, if it has a default. [JDK1.3] protected boolean equals(URL url1, URL url2) This method should return whether the two |URL|s are equals, for a protocol-specific definition of equality. The default implementation of this method performs normal field equality checking. [JDK1.3] protected int hashCode(URL url) This method should return a protocol-specific hash code of the specified |URL|. If a protocol has a nonstandard definition of equality, then this method must be overridden to return an appropriate hash code value. [JDK1.3] protected boolean sameFile(URL url1, URL url2) This method should return whether the two |URL|s refer to the same file, for a protocol-specific definition of the same file. This method should ignore the anchor part of the URL, if any. [JDK1.3] protected boolean hostsEqual(URL url1, URL url2) This method should return whether the two |URL|s refer to the same host, for a protocol-specific definition of the same host. [JDK1.3] protected InetAddress getHostAddress(URL url) This utility method returns an |InetAddress| corresponding to the IP address of the host indicated by the specified URL, or |null| of either there was a lookup error, or if no host is specified by the URL. page 420, second-last paragraph ------------------------------- "is text/html," should be all standard font, not courier. 19.10.1 Class ContentHandler / Methods ====================================== page 421, first sentence ------------------------ Replace "must provide just one method:" with "must provide just one method, although Java 2 SDK v1.3 defines an additional method that may also be optionally implemented:" append to this section ---------------------- Object getContent(URLConnection connection, Class[] classes) throws IOException This method should return the contents of the specified |URLConnection| encoded as an instance of one the specified classes (in order of preference), or |null| if none of the classes is supported. If not overridden, the default implemenation of this method calls the default |getContent()| method and returns |null| if the result is incompatible with any of the desired classes. if possible, please move 19.14 and 19.15 to 19.11 and 19.12 and please index URLEncoder and URLDecoder. ====================================================================== 20.5.1 A UDP example / Class Alarm ================================== page 449, insert a new paragraph after the second paragaph of 20.5.1 -------------------------------------------------------------------- Under the Java 2 SDK v1.3, a new class |java.util.Timer| has been provided, that implements a broad superset of the capability of this class. For compatilibity with users of Java 2 SDK v1.2 and earlier, however, we will stick with our own implementation. 23.1.2 The stub and skeleton ============================ p.504, append after the first sentence of last paragraph -------------------------------------------------------- Under Java 2 SDK v1.3, the parameter |-d .| can be omitted. [Both of these... 25.8 A CORBA bank account ========================= page 581, second paragraph, change the 2 last sentences: -------------------------------------------------------- At the time of writing, the IDL compiler that we shall use is distributed separately from the Java 2 SDK v1.2 as |idltojava|, but is included in the Java 2 SDK v1.3 as |idlj|. This compiler is required to test out the following examples. page 583, 25.8.3, replace the last sentence of the second paragraph ------------------------------------------------------------------- Different compilers will result in different names for the various support classes, however the Java SDK IDL compiler produces the following files when executed as follows: |idltojava -fno-cpp Bank.idl| (Java 2 SDK v1.2) |idlj -fall Bank.idl| (Java 2 SDK v1.3)