CSE 532 Spring 2008


Lab 0: "Card Dealer and Players"

Teams: please post the names of the 2 or 3 people on your team for Lab 0 to the course forum by 11:59pm Sunday January 27, 2008 (after which any remaining team assignments will be made by Prof. Gill)

Points: 5% of final grade

Submitted: by electronic submission to cse532@cec.wustl.edu

Due: by 11:59pm Sunday February 10, 2008


Purpose

The purpose of this assignment is to get you up to speed with using basic wrapper facades for networked OO programming, as provided by the ACE framework.

We will use these wrapper facades, and the design and implementation skills you'll develop using them, repeatedly throughout the semester. Whether or not you're already experienced with network programming, it is well worth spending some time understanding how ACE organizes the sockets API into wrapper facades, and how to use those wrapper facades to best effect. An excellent place to start is with a careful reading of chapters 2 and 3 in C++ Network Programming, Vol. 1.


Assignment

In this assignment you will write C++ client and server programs that can:
  1. access underlying operating system resources and services such as sockets,
  2. connect to one another over a network, and
  3. exchange messages in a coordinated manner.
We will start with a simple card game application in which a single server (the dealer) will listen on a commonly known port for connection requests from clients (players). When a client connects to the server, it will tell the server in which games it wishes to participate. The server will then add the client to one or more data structures, which the server uses to associate players with particular card games. Each time a client connects, the server will establish a new socket connection with that client, send a join message to all the players already in the game (and also to the player registered by the newly joining client - thus serving as its acknowldegement). To do this please perform the following tasks:

Server

Clients


Resources

There are a number of resources available that can greatly ease your task in completing this assignment. This project is designed to be very straightforward if you study and use the Wrapper Facades mentioned in this section, and may be much more difficult if you do not.

Also, there are several more mundane (but as in any software project, important) areas where you can exploit tools and examples to greatly speed your progress on this project and the ones later in the semester. In particular, code fragments and Makefile examples are provided as exemplars to follow or discard, as you choose.

Wrapper Facades

The following Wrapper Facades are provided by the ACE version installed on the CEC Linux machines in the ~cse532/ACE_wrappers/ace/ directory (also can be viewed on the web at http://classes.cec.wustl.edu/~cse532/ACE_wrappers/ace/) and are highly useful for this assignment:

There is a very nice (and short) description of how to use the Acceptor/Connector pattern in a very simple form (as much as we'll need now, before we dig into the pattern in its full generality). Code fragments for using Acceptor (as in the Server class) and Connector (as in the Client class) are on pages 67 and 59 (respectively) of the C++NPv1 book:

The container classes described in Austern Chapter 16, particularly vector and/or map, may be useful in implementing your server data structure(s) to keep track of clients and the games to which each belongs, though you will not be required to use the STL until Lab 1.

Makefile & Environment

The GNU C++ compiler (g++) is installed on the CEC Linux machines. You will need to set a few environment variables (it may be convenient to keep these in a small script file and/or simply set them in your .cshrc or .bashrc file):

setenv ACE_ROOT /home/cec/class/cse532/ACE_wrappers
setenv LD_LIBRARY_PATH ${ACE_ROOT}/ace:${LD_LIBRARY_PATH}

You will need a Makefile that links appropriately with the ACE libraries and include files. Please feel free to adapt or use the following example Makefile (for folks who took CSE 332 a.k.a. CS 342 with me previously, this may look familiar ;-).


What to Submit

README

When you have completed your program, please write up a description of your solution in a text file called README.

The first section of your README file should include:

  1. the number of the lab (e.g., "CSE 532 Spring 2008 Lab 0")
  2. the names and e-mail addresses of all team members
  3. an overview of how your programs are designed,
  4. the Wrapper Facades you used or extended and how they helped in your design and code, and
  5. insights, observations and questions you encountered while completing the assignment.

The second section of your README file should provide detailed instructions for how to:

  1. unpack your files,
  2. build your programs, and
  3. run your programs.

Please indicate any and all environment variable settings, etc. you are assuming will be needed for this.

Important: I must be able to receive your e-mail, and unpack, build, and run your programs using only the instructions in your README file and the g++ version and other tools available on the CEC Linux machines.

Electronic Submission

Please submit by e-mail to cse532@cec.wustl.edu a single file containing:
  1. your source code files,
  2. your Makefile,
  3. any example files you think useful (for example, a script with the parameters you used to run the clients and server),
  4. output files from at least one significant test of your programs, and
  5. your README file.

You can use the uuencode, tar, and zip or gzip tools to do this, as in the provided example Makefile.

Please send in a separate copy of your README file, with clear instructions on how your submission file was produced and how to unpack it using tools available on the CEC Linux machines.


Grading

Please treat this assignment as you would a commercial or research product that you are shipping to a large group of customers. Please take the time to test, document, and check your work to make sure all parts are shipped, are of high quality, and behave resonably under a range of different operating conditions. Grading will focus both on the quality of your solution and on the quality of the product itself, as it arrives at the cse532 account. To ensure the best possible result (and accordingly the highest possible grade), please pay attention to the following issues:

Correct Compilation and Operation

Your program must compile and run correctly on the CEC Linux machines using the Makefiles and source files you provide. Please make sure your program compiles without warnings, and you might even want to try running it on different compilers and fixing all the warnings for each. Problems with Makefiles will be handled similarly to missing files, with a 5 point deduction if you need to supply a new Makefile in order for me to build your solution on the CEC Linux machines.

Design Quality

Design decisions are largely yours to make, and as long as the design is concise, coherent, consistent, and addresses all design forces in the assignment, you will receive full credit. One key area to consider is whether each abstraction in your design does a single job, does that job completely, and collaborates appropriately with other abstractions. Minor deductions (1-3 points, but please be aware minor deductions can add up) will be made for abstractions that are unnecessarily large or have inappropriate inter-dependencies. Major deductions (5-15 points) will be made for larger problems like neglecting key requirements of the assignment.

Implementation Quality

How you implement your solution is again up to you, and I will take into account different approaches to implementation. Minor deductions will be made for things your program gets away with but are not good, like neglecting to check the return value from a system call or Wrapper Facade method (i.e., the program may have problems under special conditions), or calling exit(1) from inside a class method rather than providing a clean termination path. Major deductions will be made for problems that produce incorrect or extremely inefficient behavior of the program. The former kinds of errors should be eliminated during your coding and code review phases, and the latter kinds of errors should be eliminated during your testing phase, which should include running different combinations of clients and servers on the same machine and on different machines.

Coding Style

Different coding styles will also be accepted, as long as they are clear, readable, and consistent. Please code clearly with both the reader of the code and the user of the program in mind. Please use consistent indentation and placement of braces, and comment your code thoroughly. Use whitespace liberally - it's free and it makes it a lot easier to read your code. When grading, I will add tagged comments to the code indicating areas where I found particular issues to mention, whether or not points are deducted. Only minor deductions will be made for each style issue, except in extreme cases.

Documentation

Please make sure you provide adequate instructions on how to unpack, build, and run your program. Also, please make sure to document your solution. Minor or even major deductions will be made for inadequate explanation of how your solution does what it does, why you made key design choices, or how the user (or grader) can successfully build and run your program. Even if how you did something is obvious to you, please assume it is not obvious to the reader.

Missing Files

Missing files in the delivered software make it difficult or impossible to evaluate your solution. An automatic 5 point deduction will be applied for each missing or corrupted file that is submitted later on request.

Late Submission

Labs submitted within 24 hours of the deadline will be graded with an automatic 10 point deduction. Labs submitted more than 24 hours after but within 48 hours of the deadline will be graded with an automatic 20 point deduction. Labs submitted after 48 hours from the deadline will not be graded, except under extenuating circumstances. If you are running late completing the assignment, please let me know about the trouble as soon as possible, and please turn in as much as you can before each deadline so I can give at least some credit for the work you have done.