In this activity we try out the simple server discussed in section 7 of Unit 9. For a client we use the telnet program we met in Activity 9.4.
In addition to the Solution document, the project for this exercise contains two classes, which are complete:
You will also need the telnet program as in Activity 9.4.
To connect to a server on the local machine, using the HelloServer class.
Run the project to start up the server. You should get a message indicating that the server is starting up. The server is set to listen on port 3000.
You are to use telnet as a client. For this activity you do not need to be connected to the internet. See Activity 9.4 for instructions about starting up telnet if you have not done this before. At the prompt type telnet localhost 3000 and then press enter. The localhost address is a special name indicating the computer on which the telnet program is running. The 3000 indicates the port number to be used by the server.
You should see a reply from the server and then that the server closes down. This causes an end to the telnet connection and the message "connection to host lost" should appear - this does not indicate a problem.
If you want to try again, you have to run the project again to restart the server and then type the telnet command again, as above.