Homework 3

From 118wiki

Jump to: navigation, search

Homework 3

Homework 3 is the first exercise of programming with concurrency in Python. Originally, in the syllabus, this homework has a maximum score of 20 points; instead, however, this homework is 10 points, and the next homework will be called "homework 3b" and also be 10 points.


This homework is due by Midnight (11:59pm) on Monday October 9, 2006.

Submit your solution using the submit command on one of the department's Linux machines to the course directory. (Note: if you don't already have an account on the departmental machines, I'll grant you an account for this course; please contact me to get your account.) Here are instructions on how to submit:

  1. In your directory, rename, move, or delete any directory named homework1
  2. Download media:Homework3.zip, and then execute "unzip Homework3.zip". This should create a directory called Homework3. You will modify files in that directory to complete your homework.
  3. When your work is ready, run the submit script from your home directory by typing submit at the command prompt and hitting return/enter.
  4. When prompted for the File/directory name, enter homework3
  5. When prompted for the course put c118
  6. Next you will see a list of possible submission directories. For this assignment, reply homework3
  7. Done! For further help, please review the submit proceedure provided by CSG: submit.html
  8. Note: case does matter.
  9. Note: submitting the same homework assignment multiple times will overwrite the previously submitted homework with the same name and submit location.

Nim Game in TCP

The homework is to make a TCP version of the Nim game. Provided already to you in the Homework3 directory are working examples of nimTest.py, which tests your server, and nimSingle.py, which is a server that works, but only for one client at a time. The file README.txt explains what you need to do (which is to make a server that handles multiple, concurrent clients). Copy nimSingle.py, take parts of it, but then also study the examples of TCP Echo servers that use threading and select for concurrent processing of clients. You'll need to take the pattern of concurrency and modify the logic found in nimSingle.py to complete the homework.

Personal tools