You may use the echo client and server as starting point for this assignment, as described below.
/mnt/a/mdamian/bin/install_echo.shand then hit Enter. This script creates a directory called sockets in your systems directory and copies the following files in your ~/systems/sockets directory:
echoserver.c | C code for a sequential echo server | |
echoclient.c | C code for an echo client | |
nethelp.c | File containing helper functions | |
nethelp.h | Header file for functions defined in nethelp.c | |
Makefile | Compiles and links together nethelp.c and a source file |
Make sure the systems directory (created at the beginning of this semester) exists before running this script.
Invoke the server with your designated port number N as an argument:
./xechoserver NOpen a separate terminal window to test the server with telnet first. At the shell prompt, type in
telnet tanner NNow anything you type into the telnet window will be sent over the connection and echoed back to you by the server.
./xechoclient tanner NThe behavior is the same: anything you type into the telnet window will be sent over the connection and echoed back to you by the server.
Note that the server will have to pass to the thread the file descriptor for the connection returned by the accept system call, so that the thread can use it in its communication with the client.
To test your multithreaded server, open two client windows and have the clients talk simultaneously to the server.
Work incrementally, one step at a time, one command at a time. Make sure to thoroughly test and debug one command before moving on to the next.
The chat client forwards the request to join to the server. When the server receives this request from the client, it adds that client to a list of clients involved in the chat session.
The chat client forwards the request to leave to the server. When the server receives the request to leave the chat session from the client, it removes that client from its list of clients involved in the chat session.
The client should not be able to invoke the LEAVE command before joining the chat session.
The chat client forwards this request to the server. The server responds back with a list of names of those who have joined the chat session, one per line. Once the client receives this list, it displays it on the screen.
The client prints out a list of available commands.
When displayed, the message is of the form: Name: Message (Example: Melissa: Hello there)
sockets
directory create a text file named readme
(not readme.txt
, or README
, or Readme
, etc.)
that contains:
Turn in a printout copy of the readme
, chatclient.c
and chatserver.c
files, and a sample output (one printout per team). If you work on the department Unix system, you will need to copy and paste your code into a text or a Word document in Windows, since you cannot print directly from Unix.
Leave the source code for all exercises in your directory systems/sockets. Do not make any changes to these files after the due date for this assignment. If you wish to continue working on these exercises after the due date, make a copy of your directory sockets using the following Unix command:
cp -r ~/systems/sockets ~/systems/sockets-copyA new directory called sockets-copy will be created in your systems directory. You may now make any changes you want to the files in your sockets-copy directory, at any time.
No credit will be given for code that does not compile. | |
100 | Total points possible |
20 | Program compiles and runs without crashing |
35 | Server functions properly, handles multiple clients |
35 | Client functions properly, handles all communication with the server correctly |
5 | Submission includes readme file |
5 | Submission includes sample output |
+20 | Implement the multi-threaded chat application in Java as well |