Practicum in Trading Systems Development: Lab 2
Due:
Thursday, July 5, 2012, by
5:00 PM
PURPOSE AND RATIONALE
The purpose of this lab is to let students gain specific experience
with basic TCP unicast socket programming of a client and server, with
an emphasis on the server being able to handle multiple client
connections simultaneously, while managing discrete client state for
each client. The goal of this lab is to provide students with the
foundations necessary to understand the dynamics of the communication
between the Client and the ConnectionManager component in the UCEE
architecture.
NB: If you are not a CSPP
student and are in need of a CS Cluster login ID (if you don't know
what this is you are in need of one), contact the TAs immediately so
you can get set up with a cluster login ID for the labs. This
course cannot be conducted without a CS Cluster login ID. If you
already have a UofC CNET ID, you can (and should) manually apply for a
CS cluster ID here.
PRIMARY RESOURCES:
You should refer to relevant sections of the man pages for assistance
for
this lab, in addition to materials in the assigned chapters from the primary texts for
this
week (per the syllabus).
You should ssh into the cluster to perform all lab
activities.
Make sure you have read this week's assigned reading.
README
- If you are not in our course email list, please subscribe to the
cspp51025 email list here: http://mailman.cs.uchicago.edu/mailman/listinfo/cspp51025
- Turn the lab assignment as a tarball in by email to the TA
(cc'ing the instructor) by the due date
above.
- For printing out your documents, you might find the following
commands useful during your year(s) in this department:
- lpr - off line print. Note that this command is
called when you print from acroread (for .pdf files) or
gv (for .ps files)
- lpq - shows the printer queue
- lprm - removes jobs from the printer queue
- enscript - converts text files to PostScript (useful
when you want to print out text files)
- Make sure you have read the Submission Guidelines for
submission.
LAB 1
You are to write a client and server program in C++ with a makefile to
build your client and server applications. The client will be
a simple trading client, and the server will be essentially a simple
connection manager. The client will use this header
file for the
protocol for sending an order, specifically, using the ORDER
structure. The client must be launched with an argument that
represents the unique "name" of the client, which will be delivered to
the client at runtime via a command line argument. When the
client places an ORDER to the server, it will use the ORDER
structure to pass in its name (received on the command line), using the
char account field. The server will then create space to manage
that client's state via state management in the server, organized by
client name. You will need to define the class to manage client
state. You might want to use an associative STL map with unique
keys to manage the client name with the value being a pointer to the
client's state structure (all of which you will need to design and
implement).
When the server receives an order (via an ORDER message type from
the MESSAGE_TYPE enum), it will do two things: it will send a
ORDER_ACK message type back to the trader client, and it will then
print out the details of the order to the screen. The server is
responsible for handling multiple clients via select() and maintaining
the state of each client. The server is also responsible for
maintaining state information about each client connection,
including: the time of initial connection, the time of connection
termination, the total number of BUY ORDERS and the total number of
SELL ORDERS received for each client (and by calculated derivation, the total
number of ORDERS received).
Multiple threads may not be used in the solution to this
exercise. You will instead launch multiple client instances each
with a unique name from the command line argument.
More information:
Spencer's Socket Site
Beej's Guide to Network Programming
Developerweb Unix Socket FAQ
Richard Steven's Home Page
BOOST Sockets
Mark Shacklette