Book description
The new third edition of this highly regarded introduction to Java networking programming has been thoroughly revised to cover all of the 100+ significant updates to Java Developers Kit (JDK) 1.5. It is a clear, complete introduction to developing network programs (both applets and applications) using Java, covering everything from networking fundamentals to remote method invocation (RMI).Java Network Programming, 3rd Edition includes chapters on TCP and UDP sockets, multicasting protocol and content handlers, servlets, multithreaded network programming, I/O, HTML parsing and display, the Java Mail API, and the Java Secure Sockets Extension. There's also significant information on the New I/O API that was developed in large part because of the needs of network programmers.This invaluable book is a complete, single source guide to writing sophisticated network applications. Packed with useful examples, it is the essential resource for any serious Java developer.
Publisher resources
Table of contents
- A Note Regarding Supplemental Files
- Preface
- 1. Why Networked Java?
- 2. Basic Network Concepts
- 3. Basic Web Concepts
- 4. Streams
- 5. Threads
-
6. Looking Up Internet Addresses
-
6.1. The InetAddress Class
-
6.1.1. Creating New InetAddress Objects
- 6.1.1.1. public static InetAddress getByName(String hostName) throws UnknownHostException
- 6.1.1.2. public static InetAddress[ ] getAllByName(String hostName) throws UnknownHostException
- 6.1.1.3. public static InetAddress getByAddress(byte[ ] address) throws UnknownHostException // Java 1.4public static InetAddress getByAddress(String hostName, byte[] address) throws UnknownHostException // Java 1.4
- 6.1.1.4. public static InetAddress getLocalHost( ) throws UnknownHostException
- 6.1.2. Security Issues
- 6.1.3. Getter Methods
-
6.1.4. Address Types
- 6.1.4.1. public boolean isAnyLocalAddress( )
- 6.1.4.2. public boolean isLoopbackAddress( )
- 6.1.4.3. public boolean isLinkLocalAddress( )
- 6.1.4.4. public boolean isSiteLocalAddress( )
- 6.1.4.5. public boolean isMulticastAddress( )
- 6.1.4.6. public boolean isMCGlobal( )
- 6.1.4.7. public boolean isMCOrgLocal( )
- 6.1.4.8. public boolean isMCSiteLocal( )
- 6.1.4.9. public boolean isMCLinkLocal( )
- 6.1.4.10. public boolean isMCNodeLocal( )
- 6.1.5. Testing Reachability // Java 1.5
- 6.1.6. Object Methods
-
6.1.1. Creating New InetAddress Objects
- 6.2. Inet4Address and Inet6Address
- 6.3. The NetworkInterface Class
- 6.4. Some Useful Programs
-
6.1. The InetAddress Class
-
7. URLs and URIs
-
7.1. The URL Class
- 7.1.1. Creating New URLs
-
7.1.2. Splitting a URL into Pieces
- 7.1.2.1. public String getProtocol( )
- 7.1.2.2. public String getHost( )
- 7.1.2.3. public int getPort( )
- 7.1.2.4. public int getDefaultPort( )
- 7.1.2.5. public String getFile( )
- 7.1.2.6. public String getPath( ) // Java 1.3
- 7.1.2.7. public String getRef( )
- 7.1.2.8. public String getQuery( ) // Java 1.3
- 7.1.2.9. public String getUserInfo( ) // Java 1.3
- 7.1.2.10. public String getAuthority( ) // Java 1.3
- 7.1.3. Retrieving Data from a URL
- 7.1.4. Utility Methods
- 7.1.5. The Object Methods
- 7.1.6. Methods for Protocol Handlers
- 7.2. The URLEncoder and URLDecoder Classes
-
7.3. The URI Class
-
7.3.1. Constructing a URI
- 7.3.1.1. public URI(String uri) throws URISyntaxException
- 7.3.1.2. public URI(String scheme, String schemeSpecificPart, String fragment) throws URISyntaxException
- 7.3.1.3. public URI(String scheme, String host, String path, String fragment) throws URISyntaxException
- 7.3.1.4. public URI(String scheme, String authority, String path, String query, String fragment) throws URISyntaxException
- 7.3.1.5. public URI(String scheme, String userInfo, String host, int port, String path, String query, String fragment) throws URISyntaxException
- 7.3.1.6. public static URI create(String uri)
- 7.3.2. The Parts of the URI
- 7.3.3. Resolving Relative URIs
- 7.3.4. Utility Methods
-
7.3.1. Constructing a URI
- 7.4. Proxies
- 7.5. Communicating with Server-Side Programs Through GET
- 7.6. Accessing Password-Protected Sites
-
7.1. The URL Class
- 8. HTML in Swing
-
9. Sockets for Clients
- 9.1. Socket Basics
- 9.2. Investigating Protocols with Telnet
-
9.3. The Socket Class
-
9.3.1. The Constructors
- 9.3.1.1. public Socket(String host, int port) throws UnknownHostException, IOException
- 9.3.1.2. public Socket(InetAddress host, int port) throws IOException
- 9.3.1.3. public Socket(String host, int port, InetAddress interface, int localPort) throws IOException, UnknownHostException
- 9.3.1.4. public Socket(InetAddress host, int port, InetAddress interface, int localPort) throws IOException
- 9.3.1.5. protected Socket( )
- 9.3.1.6. protected Socket(SocketImpl impl)
- 9.3.1.7. public Socket(Proxy proxy) // Java 1.5
- 9.3.2. Getting Information About a Socket
- 9.3.3. Closing the Socket
- 9.3.4. Setting Socket Options
- 9.3.5. Class of Service
- 9.3.6. The Object Methods
-
9.3.1. The Constructors
- 9.4. Socket Exceptions
- 9.5. Socket Addresses
- 9.6. Examples
-
10. Sockets for Servers
-
10.1. The ServerSocket Class
-
10.1.1. The Constructors
- 10.1.1.1. public ServerSocket(int port) throws BindException, IOException
- 10.1.1.2. public ServerSocket(int port, int queueLength) throws IOException, BindException
- 10.1.1.3. public ServerSocket(int port, int queueLength, InetAddress bindAddress) throws BindException, IOException
- 10.1.1.4. public ServerSocket( ) throws IOException // Java 1.4
- 10.1.2. Accepting and Closing Connections
- 10.1.3. The get Methods
- 10.1.4. Socket Options
- 10.1.5. The Object Methods
- 10.1.6. Implementation
-
10.1.1. The Constructors
- 10.2. Some Useful Servers
-
10.1. The ServerSocket Class
- 11. Secure Sockets
-
12. Non-Blocking I/O
- 12.1. An Example Client
- 12.2. An Example Server
- 12.3. Buffers
- 12.4. Channels
- 12.5. Readiness Selection
-
13. UDP Datagrams and Sockets
- 13.1. The UDP Protocol
-
13.2. The DatagramPacket Class
- 13.2.1. The Constructors
- 13.2.2. The get Methods
-
13.2.3. The set Methods
- 13.2.3.1. public void setData(byte[] data)
- 13.2.3.2. public void setData(byte[] data, int offset, int length) // Java 1.2
- 13.2.3.3. public void setAddress(InetAddress remote)
- 13.2.3.4. public void setPort(int port)
- 13.2.3.5. public void setAddress(SocketAddress remote) // Java 1.4
- 13.2.3.6. public void setLength(int length)
-
13.3. The DatagramSocket Class
-
13.3.1. The Constructors
- 13.3.1.1. public DatagramSocket( ) throws SocketException
- 13.3.1.2. public DatagramSocket(int port) throws SocketException
- 13.3.1.3. public DatagramSocket(int port, InetAddress interface) throws SocketException
- 13.3.1.4. public DatagramSocket(SocketAddress interface) throws SocketException // Java 1.4
- 13.3.1.5. protected DatagramSocket(DatagramSocketImpl impl) throws SocketException // Java 1.4
-
13.3.2. Sending and Receiving Datagrams
- 13.3.2.1. public void send(DatagramPacket dp) throws IOException
- 13.3.2.2. public void receive(DatagramPacket dp) throws IOException
- 13.3.2.3. public void close( )
- 13.3.2.4. public int getLocalPort( )
- 13.3.2.5. public InetAddress getLocalAddress( )
- 13.3.2.6. public SocketAddress getLocalSocketAddress( ) // Java 1.4
- 13.3.3. Managing Connections
- 13.3.4. Socket Options
-
13.3.1. The Constructors
- 13.4. Some Useful Applications
- 13.5. DatagramChannel
-
14. Multicast Sockets
- 14.1. What Is a Multicast Socket?
-
14.2. Working with Multicast Sockets
- 14.2.1. The Constructors
-
14.2.2. Communicating with a Multicast Group
- 14.2.2.1. public void joinGroup(InetAddress address) throws IOException
- 14.2.2.2. public void joinGroup(SocketAddress address, NetworkInterface interface) throws IOException // Java 1.4
- 14.2.2.3. public void leaveGroup(InetAddress address) throws IOException
- 14.2.2.4. public void leaveGroup(SocketAddress multicastAddress, NetworkInterface interface) throws IOException // Java 1.4
- 14.2.2.5. public void send(DatagramPacket packet, byte ttl) throws IOException
- 14.2.2.6. public void setInterface(InetAddress address) throws SocketException
- 14.2.2.7. public InetAddress getInterface( ) throws SocketException
- 14.2.2.8. public void setNetworkInterface(NetworkInterface interface) throws SocketException // Java 1.4
- 14.2.2.9. public NetworkInterface getNetworkInterface( ) throws SocketException // Java 1.4
- 14.2.2.10. public void setTimeToLive(int ttl) throws IOException // Java 1.2
- 14.2.2.11. public int getTimeToLive( ) throws IOException // Java 1.2
- 14.2.2.12. public void setLoopbackMode(boolean disable) throws SocketException // Java 1.4
- 14.2.2.13. public boolean getLoopbackMode( ) throws SocketException // Java 1.4
- 14.3. Two Simple Examples
-
15. URLConnections
- 15.1. Opening URLConnections
- 15.2. Reading Data from a Server
- 15.3. Reading the Header
- 15.4. Configuring the Connection
- 15.5. Configuring the Client Request HTTP Header
- 15.6. Writing Data to a Server
- 15.7. Content Handlers
- 15.8. The Object Methods
- 15.9. Security Considerations for URLConnections
- 15.10. Guessing MIME Content Types
- 15.11. HttpURLConnection
- 15.12. Caches
- 15.13. JarURLConnection
-
16. Protocol Handlers
- 16.1. What Is a Protocol Handler?
-
16.2. The URLStreamHandler Class
- 16.2.1. The Constructor
-
16.2.2. Methods for Parsing URLs
- 16.2.2.1. protected void parseURL(URL u, String spec, int start, int limit)
- 16.2.2.2. protected String toExternalForm(URL u)
- 16.2.2.3. protected void setURL(URL u, String protocol, String host, int port, String authority, String userInfo, String path, String query, String fragmentID) // Java 1.3
- 16.2.2.4. protected int getDefaultPort( ) // Java 1.3
- 16.2.2.5. protected InetAddress getHostAddress(URL u) // Java 1.3
- 16.2.2.6. protected boolean hostsEqual(URL u1, URL u2) // Java 1.3
- 16.2.2.7. protected boolean sameFile(URL u1, URL u2) // Java 1.3
- 16.2.2.8. protected boolean equals(URL u1, URL u2) // Java 1.3
- 16.2.2.9. protected int hashCode(URL u) // Java 1.3
- 16.2.3. A Method for Connecting
- 16.3. Writing a Protocol Handler
- 16.4. More Protocol Handler Examples and Techniques
- 16.5. The URLStreamHandlerFactory Interface
- 17. Content Handlers
-
18. Remote Method Invocation
- 18.1. What Is Remote Method Invocation?
- 18.2. Implementation
- 18.3. Loading Classes at Runtime
-
18.4. The java.rmi Package
- 18.4.1. The Remote Interface
-
18.4.2. The Naming Class
- 18.4.2.1. public static String[] list(String url) throws RemoteException, MalformedURLException
- 18.4.2.2. public static Remote lookup(String url) throws RemoteException, NotBoundException, AccessException, MalformedURLException
- 18.4.2.3. public static void bind(String url, Remote object) throws RemoteException, AlreadyBoundException, MalformedURLException, AccessException
- 18.4.2.4. public static void unbind(String url) throws RemoteException, NotBoundException, AlreadyBoundException, MalformedURLException, AccessException // Java 1.2
- 18.4.2.5. public static void rebind(String url, Remote object) throws RemoteException, AccessException, MalformedURLException
- 18.4.3. The RMISecurityManager Class
- 18.4.4. Remote Exceptions
- 18.5. The java.rmi.registry Package
- 18.6. The java.rmi.server Package
-
19. The JavaMail API
- 19.1. What Is the JavaMail API?
- 19.2. Sending Email
- 19.3. Receiving Mail
- 19.4. Password Authentication
- 19.5. Addresses
- 19.6. The URLName Class
- 19.7. The Message Class
- 19.8. The Part Interface
- 19.9. Multipart Messages and File Attachments
- 19.10. MIME Messages
-
19.11. Folders
- 19.11.1. Opening Folders
- 19.11.2. Basic Folder Info
- 19.11.3. Managing Folders
- 19.11.4. Managing Messages in Folders
- 19.11.5. Subscriptions
- 19.11.6. Listing the Contents of a Folder
- 19.11.7. Checking for Mail
- 19.11.8. Getting Messages from Folders
- 19.11.9. Searching Folders
- 19.11.10. Flags
- 19.11.11. Event Handling
- 19.11.12. Utility Methods
- Index
- About the Author
- Colophon
- Copyright
Product information
- Title: Java Network Programming, 3rd Edition
- Author(s):
- Release date: October 2004
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9780596007218
You might also like
book
Java Network Programming, 4th Edition
This practical guide provides a complete introduction to developing network programs with Java. You’ll learn how …
book
Learning Network Programming with Java
Harness the hidden power of Java to build network-enabled applications with lower network traffic and faster …
book
TCP/IP Sockets in Java, 2nd Edition
The networking capabilities of the Java platform have been extended considerably since the first edition of …
video
Asynchronous Programming in Java
Reactive and asynchronous applications are growing in popularity, but what is the best way to build …