Modify the socket-based date server (Figure 3.21) in Chapter 3 so that the server services each client request in a separate thread. import java.net.*; import java.io.*; public class Date Server {...




Modify the socket-based date server (Figure 3.21) in Chapter 3 so that the server services each client request in a separate thread.



import java.net.*;


import java.io.*;


public class Date Server


{


public static void main(String[] args) {


try {


Server Socket sock = new Server Socket(6013);

/* now listen for connections */


while (true) {


Socket client = sock. Accept();


Print Writer pout = new


Print Writer(client. get Output Stream(), true);


/* write the Date to the socket */


pout. Print ln(new java. util. Date().to String());

/* close the socket and resume */


/* listening for connections */


client. close();

}

}


catch (IO Exception ioe) {


System. Err .print ln(ioe);


}

}

}




May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here