Observe the following code and answer the following questions. import java.io.*; import java.net.*; import java.util.Date; public class TimeServer{ public static void main(String args[]) throws Exception{ ServerSocket server = new ServerSocket(9876); while (true){ Socket client = server.accept(); //blocks until a client connects PrintStream ps = new PrintStream( client.getOutputStream() ); ps.println("Time from server:" + new Date()); client.close(); } } } What type of server this is? Is it single or multi-threaded? 2. What should be done according to you if the number of clients to this server increases? Modify the server code so that the increases number of clients can be handled by this server. 3. Explain where in your code you ensured that for every incoming request from a client, a new thread is created to serve that client
- Observe the following code and answer the following questions.
import java.io.*;
import java.net.*;
import java.util.Date;
public class TimeServer{
public static void main(String args[]) throws Exception{
ServerSocket server = new ServerSocket(9876);
while (true){
Socket client = server.accept(); //blocks until a client connects
PrintStream ps = new PrintStream( client.getOutputStream() );
ps.println("Time from server:" + new Date());
client.close();
}
}
}
- What type of server this is? Is it single or multi-threaded?
2. What should be done according to you if the number of clients to this server increases? Modify the server code so that the increases number of clients can be handled by this server.
3. Explain where in your code you ensured that for every incoming request from a client, a new thread is created to serve that client

Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 3 images









