You are to develop a localised chat server that will support a number of clients through named pipes
(FIFOs). The server and client applications will communicate through a �xed sized binary protocol.
The server will manage a global named pipe for establishing connections, after a connection has been
established it will construct a separate read and write named pipes for the client to utilise. The client
will communicate to the server over the named pipes. The server must be able to read from all clients
The global server is involved in facilitating the initial connection from clients. The initial message from
the client will be an identi�er pre�x for the named pipes to be constructed. The client will read and
write to the respective pipes that are post �xed with _RD and _WR .
This process will be responsible for creating the separate client handler daemons responding to each
client as a separate process. These processes will need to listen to all messages sent from the client
and write to back to the client and any other client’s named pipe to relay messages from client to
The global event pipe goes by the name gevent , this pipe should only be read by the global process
but can be written to by any other process.
A client-handler is spawned when a client is connected, a client-handler will be relegated to a speci�c
domain. A domain is simply a folder relative to the current working directory.
The system uses a binary message protocol to facilitate communication between the server, client-
handler and client. The server and client interaction is simply for acknowledgement and setting up
the named pipes. The main protocol will be used between the client-handler and the client. The client-
handler is spawned by the global server process to handle a client and will communicate with the
The binary message is broken up two parts, the �rst part being the type of message and the second
being contents related to the type. The type will determine how to interpret the contents in the
second part. Each message is 2048 bytes.
Under each message type in the following sections, the binary representation will be presented. The
type is at the start of the message and is 2 bytes in size.
Anatomy of a message:
|type: 2 bytes| contents: 2046 bytes|
CONNECT <identifier> <domain>
Type Decimal: 0
Type Binary: 00000000 00000000
The client will connect to the server, the server will construct two named pipes the identi�er. The
client is expected to connect to the named pipes after sending a well formed connect message to the
The identi�er part of the message is maximum 256 characters ASCII encoded. The domain
component will map to a folder relative to the current working directory.
Type Decimal: 1
Type Binary: 00000000 00000001