Information Security |
Homework: 0 1 2 3 4 56 7 |
You must do this assignment yourself, but you may ask other students for hints or advice.
You can get a zip-file containing the chat software here. The software is written in Java.
You can do this assignment (and all other programming assignments) on any machine you like, but your homework solutions must compile and run on the Computer Science Linux machines (i.e., linux.cs.princeton.edu). Java code tends to be very portable, so we don't anticipate many portability problems, but it's your responsibility to verify that your code works on the C.S. machines.
If you don't have an account on the C.S. machines, let us know and we'll get you one.
This is a good time to share hints with each other.
The software actually consists of two programs, ChatServer and ChatClient, which share some code. ChatServer listens for connections from ChatClients, and manages a chat room for these ChatClients. You can run as many ChatClients as you want. Each ChatClient represents one user who is joining the chat room.
First, you'll need to edit the "config.txt" file to configure the service so that it doesn't conflict with other students' versions of the service. The issue here is that each student's ChatServer will want to listen on a particular port on the machine; if two ChatServers try to listen on the same port, one of them will be unable to do so. So each student needs to use a unique port number. To do this, edit the config.txt file and follow the directions in that file. When you're done, save the file and exit the editor.
Now you're ready to run the program. Open four shell windows (or command prompt windows on Windows), all located in the directory containing the compiled code. In the first window, type the command "java ChatServer". The ChatServer program will start running, but it won't provide any output. It will just sit there, waiting for connections from clients. If you see an error message, something is wrong and you need to figure out what it is. Feel free to ask for help if you have trouble.
Now go to a second window and type "java ChatClient Alice". This will start the chat client, but it won't print anything.
Go to the third and fourth windows and type "java ChatClient Bob" and "java ChatClient Charlie" in each of them. This will start two more chat clients (for a total of three). As of yet, none of the windows will have printed anything. If you see any error messages during these steps, you'll have to figure out what is wrong. Feel free to ask for help if you have trouble.
Now you're ready to chat. Go to one of the ChatClient windows and type a line of text, hitting Return at the end. That line of text should appear in the other two chat windows.
Switch back and forth a few time between the ChatClient windows, typing lines of text to simulate a chat session between three people. Whenever you hit Return in a window, the line of text you just typed should be echoed into the other windows.
That's all. In the next assignment we'll start improving the chat service's security. You might want to start reading the chat service's code to figure out how it works.