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).