Introduction
In this request you will be creating a chat service much like Google’s Hangouts, called Wolfie Chat. The goal is to learn about network programming in C. You will implement the service so that it adheres to the Wolfie Protocol.
The concept of a protocol is an important one to understand. When implementing the protocol you need to follow the requirements and description TO THE LETTER. The idea is to create a standard so that anyone implementing the Wolfie Protocol will be able to connect and operate with any other program implementing the same protocol. Any client and chat should work with any server if the protocol is used correctly (HINT HINT think grading).
Certain public networks like wolfienet secure or starbucks will not allow you to connect your client and server together over the network. You may also want to test your client by connecting to another group’s server, and your server by having other group’s clients connect to it. This is a good way to ensure that the protocol is implemented correctly in your client/server programs. While we encourage testing this way, THIS IS NOT an open invitation to share code with other groups. You should not be showing or sharing code with anyone else. To perform these tests you should simply be telling your client programs to connect to the IP address and port number at which these servers are running at. You have been warned!
Groups
In this request you are allowed groups of two members. Unless stated otherwise, we will assume that you are in the same group as the previous request. If you wish to divorce your partner from the previous request and assemble a new group please follow the directions in hw4.
Getting started
Make the directory hw5 in the root of your git repository. All files which you create for this request should be placed in this directory. You should also create a Makefile, which generates the server program called server, a client program called client, and your chat program called chat. When we navigate to the hw5 directory and type make these three programs should be generated.
1 | $ cd hw5 |
A good strategy for splitting up the work in this request should be to have one partner create the client/chat program and the other partner create the server. Test out each part as you implement it to ensure that it works (don’t just build the entire thing separately and hope it all works in the end.) It’s also okay to test both the server and client locally on your own machine, but you really should test it out over a real network as well.
Helpful Resources
You should make sure you understand chapter 11, 12.2, and 12.3 in your textbook. Also if you didn’t understand files, fork, execute, and pipes from the previous request, make sure you review chapter 10.1-10.4 and 10.6-10.12.
An AMAZING reference on sockets which summarizes the man pages can be found here (Don’t worry that the site is called python). Additionally you may also want to read Bee’s Guide to Network Programming. It has a good mix of tutorials, explanations, and descriptions of the functions you need to use for this request. You may also want to consider using wireshark or tcpdump to monitor the network packets.
Things to be aware of
Aside from the issues which occur in the protocol (such as a user with duplicate names), you also need to handle other external errors such as connections getting lost, client program getting killed, server program getting killed, etc. You should look to handle:
- EINTR
- EPIPE
- ECONNREFUSED
- ECHILD
- EJNVAL
- SIGCHILD