Question
Must comment on the code at every /* Comment Here */ section about what the code is doing. import java.io.*; import java.net.*; public class HttpHeader
Must comment on the code at every "/* Comment Here */" section about what the code is doing.
import java.io.*; import java.net.*;
public class HttpHeader { public static void main(String args[]) throws java.io.IOException { if (args.length < 1) { System.err .println("Usage: java HttpHeader
final int PORT = 80; Socket sock = null; BufferedReader in = null; PrintWriter out = null; String requestedDocument = "";
if (args.length == 2) requestedDocument = args[1];
try { /* Comment Here */ sock = new Socket(args[0], PORT);
/* Comment Here */ in = new BufferedReader( new InputStreamReader(sock.getInputStream())); out = new PrintWriter( new OutputStreamWriter(sock.getOutputStream()));
/* Comment Here */ String message = "GET /" + requestedDocument + " HTTP/1.1 Host: " + args[0] + " "; out.print(message); out.flush();
/* Comment Here */ String line; while ((line = in.readLine()) != null) { if (line.length() == 0) break; System.out.println(line); } } /* Comment Here */ catch (Exception e) { System.err.println(e); } finally { // close all streams if (in != null) in.close(); if (out != null) out.close(); if (sock != null) sock.close(); } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started