You have this code: public class Server { public static void…

You have this code: public class Server { public static void main(String[] args) throws Exception { ServerSocket serverSocket = new ServerSocket(8080); while (true) { Socket clientSocket = serverSocket.accept(); handleClient(clientSocket); } } static void handleClient(Socket socket) throws Exception { // Process client request (takes 10 seconds) Thread.sleep(10000); socket.close(); } } What happens when multiple clients try to connect? Select all that apply

Which of the following is the CORRECT pattern for a multi-th…

Which of the following is the CORRECT pattern for a multi-threaded server? while (true) { Socket client = serverSocket.accept(); new Thread(() -> handleClient(client)).start(); } new Thread(() -> { while (true) { Socket client = serverSocket.accept(); handleClient(client); } }).start(); Socket client = serverSocket.accept(); while (true) { new Thread(() -> handleClient(client)).start(); } while (true) { handleClient(serverSocket.accept()); }

Consider this scenario: Socket clientSocket = new Socket(“lo…

Consider this scenario: Socket clientSocket = new Socket(“localhost”, 8080); // Send request 1 out.write(“Request 1”.getBytes()); // Read response 1 int bytes1 = in.read(buffer); // Send request 2 out.write(“Request 2”.getBytes()); // Read response 2 int bytes2 = in.read(buffer); Which statements are TRUE? (Select all that apply)

What is the difference between a public IP and a private IP?…

What is the difference between a public IP and a private IP? Explain their roles in networking and why distinguishing between them is important.  Why is it necessary to differentiate between public and private IPs when running a server accessible from other networks? How do these IP types impact the server’s configuration and accessibility?  Explain why private IPs cannot be directly accessed over the internet without additional network configurations.