String message, response;
System.out.print("Enter message: ");
message = userEntry.nextLine();
output.println(message); //Step 3.
response = input.nextLine(); //Step 3.
"\n* Closing connection… *");
link.close(); //Step 4.
"Unable to disconnect!");
For the preceding client-server application to work, TCP/IP must be installed
and working. How are you to know whether this is the case for your machine? Well,
if there is a working Internet connection on your machine, then TCP/IP is running.
In order to start the application, fi rst open two command windows and then start the
server running in one window and the client in the other. (Make sure that the server
is running fi rst, in order to avoid having the client program crash!) The example
screenshots in Figs. 2.3 and 2.4 show the dialogues between the server and two
consecutive clients for this application. Note that, in order to stop the TCPEchoServer
program, Ctrl-C has to be entered from the keyboard.