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.

You are building a Task Assignment System where clients can:…

You are building a Task Assignment System where clients can: Create new tasks with a description and priority (LOW, MEDIUM, HIGH) Assign tasks to team members Mark tasks as complete List all tasks for a specific team member Design a proto-based protocol for this system. For each operation, specify: The request format (what fields are needed) The success response format At least one error response List other error cases that need to be handled You only need to show 2 operations: CREATE_TASK and ASSIGN_TASK.

A student wrote this client code: public class Client { publ…

A student wrote this client code: public class Client { public static void main(String[] args) { try { Socket socket = new Socket(“localhost”, 8080); OutputStream out = socket.getOutputStream(); out.write(“Hello Server”.getBytes()); InputStream in = socket.getInputStream(); byte[] buffer = new byte[1024]; int bytesRead = in.read(buffer); System.out.println(“Response: ” + new String(buffer, 0, bytesRead)); } catch (Exception e) { e.printStackTrace(); } } } What issues are in this code?

You are building a Restaurant Reservation System where clien…

You are building a Restaurant Reservation System where clients can: Make a reservation (date, time, party size, customer name) Cancel a reservation by reservation ID Check availability for a given date and time List all reservations for a customer Design a JSON-based protocol for this system. For each operation, specify: The request format (what fields are needed) The success response format At least one error response List other error cases that need to be handled You only need to show 2 operations: MAKE_RESERVATION and CANCEL_RESERVATION.