In this activity we try out the name server discussed in section 8.1 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 use the NameServer class and the telnet program, and to observe how they communicate.
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.
Once the telnet client has connected to the server, the server waits for a message from the client containing a user name. Type one of the user names listed in the setUpNameDatabase method and press enter. Note that the first name you type in may not be displayed on the screen.
You should get a reply indicating the corresponding e-mail address. Note that you can only get a match for the email address if you had entered the name exactly as given, including capital letters. You can continue entering as many user names as you like. Any user name not in the database should receive a reply indicating this fact. To terminate the connection, you enter Exit (exactly like this) and press enter. This should close down the telnet connection but does not cause the server to close.
Unlike the simple server in previous activities, this server keeps running even after the telnet client has terminated. You can run the telnet client again and send some more user names to the server. It should respond as before. The only way to end this server is to forcibly terminate the program the program from NetBeans.
For Vista and Windows 7 to disable telnet
For Windows XP the client is enabled by default. The server should
normally be disabled. You can check here: