Question: Java: Briefly explain the code in each area with /*comment*/ above it import java.net.*; import java.io.*; public class MessageServer { 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 MessageServer { public static final int PORT = 6100;

public static void main(String[] args) { Socket client = null; ServerSocket sock = null; BufferedReader reader = null;

try { sock = new ServerSocket(PORT); /* Comment Here */ while (true) { client = sock.accept();

reader = new BufferedReader(new InputStreamReader(client.getInputStream()));

Message message = new MessageImpl(reader.readLine());

/* Comment Here */ message.setCounts();

/* Comment Here */ ObjectOutputStream soos = new ObjectOutputStream(client.getOutputStream()); soos.writeObject(message); System.out.println("wrote message to the socket");

client.close(); } } catch (IOException ioe) { System.err.println(ioe); } } }

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!