Simple client/server event booking system for a Computer Networks project.
This repository contains a C implementation of a small booking platform with separate client and server programs and a shared common library.
Structure
client/— client source and helpers.server/— server source, stores events and user data.common/— shared utilities used by both client and server.
The repository includes a Makefile that compiles the code and places executables in the repository root. To build everything, run:
make
Notes:
- The Makefile produces executables in the repository root. The Makefile will name the executables
userandESto avoid colliding with directories. make cleanremoves object files, the staticcommonlibrary and the built executables.
Open two terminals (one for server, one for client).
- Start the server (terminal A):
./ES [-p ESport] [-v]
ESport- the port number where the event server is going to accept requests (UDP & TCP). Default value is 58041.- If the
-voption is set, the program operates in verbose mode, outputting to the screen a short description of the received requests (UID, type of request) and the IP and port originating those requests.
- Start the client (terminal B):
./user [-n ESIP] [-p ESPORT]
ESIP- the IP address of the machine where the event server is running. Default value is localhost.ESport- the port where the event server is accepting requests (UDP & TCP). Default value is 58041.
Both the user and the event server have a timeout value for communicating with each other. You can change this value by changing the TIMEOUT_SECS macro in common/validate.h. You then need to make clean and make again.
A value of 0 means that requests will never timeout.
Run the client and type commands at the > prompt. Available commands include:
login <uid> <password>changePass <old> <new>unregisterlogoutexitcreate <name> <event_name> <event_date> <num_attendees>close <eid>myevents/myelistshow <eid>reserve <event_id> <num_seats>myreservations/myrhelp
We followed the in-class guide with the following modifications:
-
Instead of a single
END.txtfile, we use two separate files:FINISHED.txtandCLOSED.txt.FINISHED.txtindicates that the event date has already passed, whileCLOSED.txtindicates the event was closed manually by its creator. Splitting these statuses makes it easier and faster to verify an event's current state. -
For reservation files, we use naming conventions that make intent and provenance clear:
- In the
EVENTSdirectory, reservation files follow the formatRES_uid_date_time.txt(as specified in the assignment), so each file clearly identifies the user who made the reservation and when. - In the
USERSdirectory, reservation files are namedRES_eid_date_time.txtso it is immediately clear which event that user reserved.
- In the
These small changes improve clarity and simplify state checks when the server needs to determine whether an event is finished, closed, or which event a user reserved.
- The client handles Ctrl-C (SIGINT) and, if logged in, will attempt to logout before exiting.
- The server may install a SIGINT handler to enable graceful shutdown; check
server/utils.cfor details.