CSCD 330 Lab 4
Client/Server Program

Please type or write your answers to the questions and email them with CSCD330-Lab 3 in the subject line.
Note: The application is a KnockKnock joke generator where the client connects to the server and you ask it a KnockKnock joke.
The joke protocol goes like this:

Server: "Knock knock!"
Client: "Who's there?"
Server: "Dexter."
Client: "Dexter who?"
Server: "Dexter halls with boughs of holly."
Client: "Groan."

1. Download the file from our class Website Knock Knock Server
File name: Save this File as
2. Copy and paste the client code from the following link. Client code is here: Client Code for Lab. Save it in a file called
Compile the .java files.
3. Open up two windows on your local machine and communicate between client and server using the KnockKnock protocol.
In other words, tell jokes between the client and server.
Use the command line to start the server: java KnockKnockServer and in the second window, type: java KnockKnockClient
4. Optional, you can change the jokes if you like.
5. If you are in the Lab, you can trade IP addresses with a neighbor and recompile your Client programs. Now one of you start up the server and one start his/her client. Tell jokes between machines. Then, reverse the process and do it again to get the feel of connecting to a Server on a different machine. If you are doing the lab at home, just skip this step.

After getting the chance to try out both the client and server KnockKnock programs, answer the questions below.


  1. What happens if you start the client first and then the Server?
  2. What happens if you start one client and then start a second client when the first hasn't finished?
  3. What can you do to the server to allow it to handle multiple clients at once? Sketch out briefly a few lines of pseudocode for your solution to this problem.
  4. What happens if you have the wrong IP address of the host where the server is running? Hint: Try it!
  5. How do you look up the IP address of your own machine in Linux?