Question: Write a client/server program using the Java socket package. The client prompts the user for an operation command. The client sends the command to the
Write a client/server program using the Java socket package. The client prompts the user for an operation command. The client sends the command to the server, and then displays the servers response. The server receives an operation command from the client, executes the command, and sends back a response to the client.
The client program should be able to request the following operations: a) whoAMi: server responds with the IP address of the client. b) startEcho: server responds with the string listening, after which all lines sent by the client to the server will be simply echoed back to the client by the server, including all operation commands except stopEcho. c) stopEcho: server responds with the string stopped if and only if the previous server executed command was startEcho. At this point the server will stop echoing and accept operation commands for execution. Otherwise, the operation command does nothing. d) bye: server responds with the string bye, and then the client disconnects from the server.
3 An example of user interaction is provided below. The > symbol identifies the command prompt. C:\>java myClient 10.1.20.20 9999 Session has been established. operation> whoAMi server: 10.1.20.19 operation> stopEcho operation> startEcho listening echo> hello server: hello echo> whoAMi server: whoAMi echo> stopEcho stopped operation> bye bye Session is terminated. C:\>
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
