Project 3: CHATTY - A Client / Server Chatt Room.
Assignment Day | September 15, 2009 |
Due Date | September 24, 2009 (Thursday) |
Collaboration Policy - Read Carefully
You may work on this project in teams of two or individually. You may discuss this assignment with other students and groups in the class and ask and provide help in useful ways, preferable over our email list so we can all benefit from your great ideas. You may consult (but not copy) any outside resources including books, papers, web sites and people (but no penguins or sea urchins).
If you use resources other than the class materials, indicate what you used along with your answer.
You have probably guessed it by now - every project will have a similar paragraph to the one above but with slight variations, of-course.
Objective:
The goal of this project is to introduce you to the concepts of processes and inter-process communication.
The project is purposely losely defined so there are opportunities for you to be creative and hopefully have fun. Please share ideas on the email list - I always enjoy hearing what you are working on.
The general idea is to implement a client / server chat room. The chat needs to support multiple clients - i.e., multiple chatters and one server that relay messges to the other chatter clients.
Key Concepts and Goals:
- Socket programming
- Process communication
- Multitasking
- Deep C Programming Skills
Tutorial / References
Socket Programming Resources:Beej's Guide to Network Programming: Jim Frost Guide to Socket Programs: Jeff Donahoo's Code/Book: C programming/tutorials:There are several C resources on the net. Here are some that may be useful: http://www.strath.ac.uk/IT/Docs/Ccourse/ http://www.lysator.liu.se/c/bwk-tutor.html GDB (GNU Debugger) tutorial: C Frequently Asked Questions: |
If you find other resources please post links on the mailing list for the class. |
Design of Chat Server / Client Project:
You will write two programs a server that both waits for client connection and relay messages to connected clients and a chat client that connects to the chat server at a specific port. This project is open ended and you can design it however you like (: so this project is for the adventures. Also - you may discuss and are encouraged to discuss your project / design on the class email list.
What is a Chat Room?
Some of you may be familiar with some forms of Chat Rooms over the Internet such as Instant messenger, Skype, talk and more. For this assignement assume a chat room is created by a server, the server allows the creation of different chat rooms identified by a host name and port number. People can "subscribe to" or "enter" a chat room. A client can send messages, and they instantly appear on the screens of everyone else in the room.
You will be given C-code for an echo server and a client where the server echos back strings from a client. Your project is to extend the server and client to a Chat Room application.
A Possible Sequence of Events (you may deviate from this):
An possible sequence of events between a server and a client is listed below.
1. start server on server machine with specified port number:
chat-server 127.0.0.1 5000
2. start client on client machinechat-client 127.0.0.1 5000
3. client, Jane, connects to the server(via chat-client program).
4. User Jane (client code) types a text to serverExample:
'Hello this is Jill!'6. Server echos back the text to other connected clients preceded by the name of the original client.
Jill said> 'Hello this is Jill!'
8. The client closes the connection by sending 'bye'9. The server notes other connected clients:
Jill has left the chat room>
Client Server Interaction:
Your server should be able to accept multiple connections (from different hosts). It should be able to simultaneously listen for incoming connections as well as keep reading from connections that are already open.
Since many of the calls that we talked about in class are blocking calls (e.g. accept(), recv()). They may stall the program execution until data arrives. For example if your server is blocking on an accept() it cannot receive data at the same time.
There are several solutions to this problem. One solution is to use multiple processes (using fork()), another is to use threads (using pthreads)
There are two example programs of multitasking servers in the project3 directory (see this link) - one is called TCPEchoServer-Fork.c and is listed under the subdirectories echo, the other is listed under the subdirectory pong (last semester's project). Makefiles/README.txt for the echo server.
Design Decisions:
You need to design how the server knows how lines are termininated. You do need to design communciaiton for high performance.Submitting:
You need to name the directory of your source code "project3/". You must to include a README.txt file desribing how to run and compile your program. You also need to include a Makefile, you can find an example makefile in the subdirectories of the project3 directory accessible from the schedule web page.
|
Optional: