Homework 4, A Chat System
Short Description:
Do Something
Goals
When you finish this homework, you should have:
- Written several programs involving sockets.
Formal Description
Create a chat system. This system should support three different "programs".
- A chat server (50%)
- A message writer (25%)
- A message listener (25%)
The chat server
This program should bind to a port and listen for UDP messages. These messages should be in the following format:
- quit
- Ignore all other text in the message. Stop the server.
- debug
- Ignore all other text in the message. Print to standard out all connected clients.
- join:nickname
- Add a listener to the server.
- The nickname will be a single word (no white spaces)
- Ignore everything after the nickname
- The nickname may not be "ALL" in any form.
- Add the nickname, port and host to the list of listeners.
- remove:nickname
- The rules for nickname above apply.
- This removes the nickname from active listeners.
- The port and host must match.
- Ie dan@mirkwood:10001 and dan@mirkwood:10002 are different listeners. Only remove the one that sent the remove request.
- post:from_nickname:to_nickname|ALL:message
- The rules for nickname above apply.
- Send the message to everyone associated with the to_nickname.
- If the to_nickname is ALL, send the message to all registered listeners.
- All messages should only contain printable ascii characters. For security only transmit messages which contain characters that return true to the isprint function. The message may contain a single null (0) at the end of the message.
I used a vector to maintain the listeners, a map might work, but you need to handle nickname collisions.
The server may be very verbose, (you could add that as a command) and print out each message received and perhaps describe the action.
You may use any anything in the standard library.
While creating your server, you can use netcat as both a listener and a writer. To receive credit, however, you must implement both a listener and a writer.
A message listener
This should bind to a port and continue to run. It should send a join message to the chat server, then receive messages in the "post" format above. It should present the messages, along with the sender (from_nickname) in a nice format.
Allow the user to quit the program, and send a remove message when this happens.
A message writer
This program can be continuous or one shot. It should send post messages to the server.
Notes
All communications should be via INET domain sockets using UDP as the protocol.
If you wish you can create an integrated listener and writer.
Your server must compile and run on thought, and your clients must compile and run on memory.
Make sure that you provide instructions for using your clients and server.
You should be able to interact with other student's software.
Required Files
The source code and building instructions for your code in a tar or zip file. You should include documentation if it is needed.
Submission
Submit the assignment to the D2L folder homework 4 by the due date.