Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Revise this client to make it a bad client where it gives poor services to the server. TCPEchoClient.java 0 import java.net.* // for Socket 1

image text in transcribed

image text in transcribed

Revise this client to make it a bad client where it gives poor services to the server.

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 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

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

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions