Activity 9.8 - Developing the full client-server name service

Topic

In this activity we try out the name server discussed in section 8.1 of Unit 9, using the client code discussed in section 8.2. This is similar to Activity 9.7 except that we are using our own client code instead of the telnet client.

Materials

For this activity there are two separate projects, Ex9_8Server and Ex9_8Client. The instructions for this activity and the Solution document can be accessed from both projects.

You should start from the server project if you have not already done this.

In addition to the Solution document, the server project for this exercise contains two classes, which are complete:

In addition to the Solution document, the client project also contains two classes, which are complete:

Task

To use the NameClient class and the NameServer class and observe how they communicate.

Instructions

  1. Open the project Ex9_8Server and run it, 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.

  2. Open the project Ex9_8Client and run it. For this activity you do not need to be connected to the internet, since both the client and the server are running on the same computer. In this case, the client has a graphical user interface (GUI).

  3. In the appropriate text box of the client GUI, enter a user name from those defined in the NameServer method setUpNameDatabase. Press the Go button to send the user name to the server. You should see a reply from the server in the other text box, indicating either the corresponding e-mail address or a message if the name cannot be found in the database. You can continue entering a user name and receiving a reply as many times as you like. To quit you click on the Quit button. As in Activity 9.7, this will cause the client to terminate but not the server.

  4. The server continues running even after the client has terminated. You can start up another client by running the project again and then send some more user names to the server. It should respond as before. Note that entering Exit as a username gives no response on the user interface, but does close the server connection stream.

    The server runs endlessly and can only be stopped by terminating it from NetBeans.