Question: 4. Servers are supposed to run for a long time without stoppingtherefore, they must be designed to provide good service no matter what their clients

4. Servers are supposed to run for a long time without stoppingtherefore, they must be designed to provide good service no matter what their clients do. Examine the server TCPEchoServer.java and list 2 things you can think of that a client might do to cause the server to give poor service to other clients. Suggest improvements to fix the 2 problems that you find.

Based on your answers, or more specifically, your answers to "Examine the server TCPEchoServer.java and list anything you can think of that a client might do to cause it to give poor service to other clients," and revise TCPEchoClient.java to implement such a client, which I call a bad client. Your bad client should attempt to cause the server to provide poor services, in at least 2 different ways. (5 points, 2.5 for each bad behavior)

Then Based on your answers to "Suggest improvements to fix the problems that you find," revise TCPEchoServer.java to incorporate those improvements. You can call this improved server a bullet-proof server. (5 points, 2.5 for each improvement)

!!READ THIS!!: (To Chegg Answerer) I have asked this question 3 times already and gotten unrelated or insufficient/lousy answers, I understand how this code works and one way to make a bad client is by making it repeatedly write to the server thus blocking it from accepting messages from other clients, I fixed this by making the server able to accept multiple clients by creating multiple threads. I can't think of another way to make the client do something bad to the server so that is what I need help with. NOTE that it should be a change that can be implemented into the code of TCPEchoClient that makes it to something bad, NOT something bad about it already that can be improved. Then I need help with how to fix said change in TCPEchoServer. Thank you.

TCPEchoServer.java

4. Servers are supposed to run for a long time without stoppingtherefore,TCPEchoServer.java

they must be designed to provide good service no matter what their

import java.net.* I/ for Socket, ServerSocket, and InetAddress 5 import java.io.*; /7 for IOException and Input/OutputStrearm 6 7 public class TCPEchoServer 9 private static final int BUFSIZE= 32; // Size of receive buffer 10 11e public static void main(String[I args) throws IOException 12 13 14 15 16 17 18 19 20 21 if (args.length !-1) // Test for correct # of Aras throw new IllegaLArgumentExceptionC" Parameter(s): "); int se rvPort = Integer.parseInt(args[0]); // Create a server socket to accept client connection requests ServerSocket servSock - new ServerSocket(servPort); int recvMsgSize; // Size of received message byte receiveBuf = new byte [BUFSIZf]; // Receive buffer 23 24 25 26 27 28 29 30 31 32 while (true) I/ Run forever, accepting and servicing connections socket c1ntSock = servSock.accept(); // Get client connection SocketAddress clientAddressclntSock.getRemoteSocketAddressO; System.out.println( Handling client at " +clientAddress); InputStream in = clntSock.getInputStream(); OutputStream out = clntSock.getOutputStream(); // Receive until client closes connection, indicated by -1 return while ((recvMsgSize-in.read(receiveBuf)) !- -1) 34 35 36 37 38 39 40 41 out.write(receiveBuf, 0, recvMsgSize); clntSock.closeO; // Close the socket. We are done with this client! NOT REACHED

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!