Question: Modify the socket-based date server (Figure 3.27) in Chapter 3 so that the server services each client request in a separate thread. import java.net.*; import

Modify the socket-based date server (Figure 3.27) in Chapter 3 so that the server services each client request in a separate thread.
import java.net.*; import java.io.*; public class DateServer { public static void main(String[] args) { try { Server Socket sock = new ServerSocket (6013); /* now listen for connections */ while (true) { Socket client = sock.accept(); PrintWriter pout = new PrintWriter (client.getOutputStream(), true); /* write the Date to the socket / pout.println(new java.util.Date().toString(); /* close the socket and resume */ /* listening for connections / client.close(); } catch (IOException ioe) { System.err.println(ice); } > } Figure 3.27 Date server
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
