Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 [document name]"); System.exit(0); }

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2016 Riva Del Garda Italy September 19 23 2016 Proceedings Part 3 Lnai 9853

Authors: Bettina Berendt ,Bjorn Bringmann ,Elisa Fromont ,Gemma Garriga ,Pauli Miettinen ,Nikolaj Tatti ,Volker Tresp

1st Edition

3319461303, 978-3319461304

More Books

Students also viewed these Databases questions

Question

State the importance of control

Answered: 1 week ago

Question

What are the functions of top management?

Answered: 1 week ago

Question

Bring out the limitations of planning.

Answered: 1 week ago

Question

Why should a business be socially responsible?

Answered: 1 week ago