Question: Must comment on the code at every /* Comment Here */ section about what the code is doing. import java.io.*; import java.net.*; /** * This
Must comment on the code at every "/* Comment Here */" section about what the code is doing.
import java.io.*; import java.net.*;
/** * This program is a very simple Web server. When it receives a HTTP request, * it just sends the request back to the client. This default port this * server listens to is 1500. * * Usage: * * java HttpRequestMirror
if (args.length == 1) port = Integer.parseInt(args[0]);
try { /* Comment Here */ ServerSocket ss = new ServerSocket(port); System.out.println("Server bound at port " + ss.getLocalPort());
while (true) { Socket client = ss.accept();
/* Comment Here */ BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream())); PrintWriter out = new PrintWriter(new OutputStreamWriter(client.getOutputStream()));
/* Comment Here */ out.println("HTTP/1.1 200 "); out.println("Content-Type: text/plain"); out.println(); // send the empty line out.flush();
/* Comment Here */ String line; while((line = in.readLine()) != null) { if (line.length() == 0) break; out.println(line); }
/* Comment Here */ out.close(); in.close(); client.close(); } } catch (Exception e) { System.err.println(e); System.err.println("Usage: java HttpRequestMirror
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
