After finishing program 3, you should now have a card dealer server that is using TCP to communicate with the clients. The next step is to replace the polling loop with something a little more reasonable. The next easiest alternative is to use the select() call.
You should read about the select call in the Unix Network Programming Manual. There are a number of other examples of using select that can be found with a little Googling, and I have several books in my office that have examples of using select.
NEW: I have a few pages out of a book that explains the select() call better than I have been doing - it might provide a little additional information. The pages are from Unix Network Programming, 1st Ed. by W. Richard Stevens. I also have similar info from the second edition of the same book. It has a litte more complete description of the conditions under which bits get set in the different fd_sets.
For this assignment, you need to modify your TCP card dealer server and from the last assignment to use select(). You should change out the polling loop for a select loop, modify how you handle the server and client sockets so that you also maintain the file descriptor bitmaps (fd_sets) used as input to select, and change the loop to correctly process events that are indicated by the descriptor sets returned by select.
Modify your server as specified - you can give it a new name, but everything else should work just as it did for the previous program. Once good thing is that you should not need to make any changes to the client program - the same client should be able to connect with the server for program 3 or program 4 (and the next two servers as well).
You should again do some design work before you start hacking away on code - make sure you know how you are going to manage your list of sockets, and how you will build the select fd_sets from this list.
You should continue to refine the library of socket functions - add routines to the server code that allow you to use select to manage a set of sockets on the server side. Clean up any code that might need it for both the server and client.
You should include the following: