Question: Java: Briefly explain the code in each area with /*comment*/ above it import java.net.*; import java.io.*; public class MessageClient { public static final int PORT

Java: Briefly explain the code in each area with /*comment*/ above it

import java.net.*; import java.io.*;

public class MessageClient { public static final int PORT = 6100; public static final String host = "127.0.0.1";

public static void main(String[] args) throws IOException { Socket sock = null; if (args.length != 1) { System.err.println("Usage: java MessageClient "); System.exit(0); } try { /* Comment Here */ sock = new Socket(host, PORT);

PrintWriter pout = new PrintWriter(sock.getOutputStream(),true);

pout.println(args[0]);

/* Comment Here */ ObjectInputStream ois = new ObjectInputStream(sock.getInputStream());

Message message = (Message) ois.readObject(); System.out.println(message.getCharacterCount()); System.out.println(message.getDigitCount()); } catch (IOException ioe) { System.err.println(ioe); } catch (ClassNotFoundException cnfe) { System.err.println(cnfe); } finally { sock.close(); } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!