Java Reference
In-Depth Information
SocketServer has many of the same socket options available as the Socket class. One
important option that they share is the SO_TIMEOUT option. With the ServerSocket class, the
SO_TIMEOUT option specifies how long the server should wait for an incoming socket connec-
tion with the accept method.
When the accept method times out, a java.net.SocketTimeoutException is raised. Let's
look at a sample socket implementation in Listing 7-2 for our networking version of Denny's
DVDs. Figure 7-4 shows a high-level view of how we must implement our socket solution.
Figure 7-4. Socket classes
Listing 7-2. DVDSocketServer.java
package sampleproject.sockets;
import java.io.*;
import java.net.*;
import java.util.*;
import java.util.logging.*;
import sampleproject.db.*;
Search WWH ::




Custom Search