Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Improve this client and list it's problems. TCPEchoClient.java 0 import java.net.* // for Socket 1 import java.io.*; // for IOException and Input/OutputStream 3 public class

image text in transcribed

image text in transcribed

Improve this client and list it's problems.

TCPEchoClient.java 0 import java.net.* // for Socket 1 import java.io.*; // for IOException and Input/OutputStream 3 public class TCPEchoClient i 5 public static void main(String[] args) throws IOException i 4 6 7 8 9 10 if ((args, length 3)) // Test for correct # of args throw new IllegalArgumentException("Parameter(s): []"); String server - args[0]; // Convert input String to bytes using the default character encoding bytel] byteBuffer-args[1].getBytes); // Server name or IP address 12 13 int servPort - (args.length-- 3)? Integer.parseInt(args[2]) :7; 15 16 // Create socket that is connected to server on specified port Socket socket - new Socket(server, servPort); System.out.println("Connected to server.. .sending echo string"); 18 19 20 21 InputStream in - socket.getInputStream); OutputStream out - socket.getOutputStream) 23 24 25 26 27 28 29 30 31 out.write (byteBuffer); // Send the encoded string to the server // Receive the same string back from the server int totalBytesRcvd 0; // Total bytes received so far int bytesRcvd; while (totalBytesRcvd

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_2

Step: 3

blur-text-image_3

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

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions