This project is a concurrent client-server markdown editor built with:
- A signal-based handshake so clients can request a session from the server.
- Per-client FIFO channels for isolated client-to-server and server-to-client traffic.
- Role-based access control from
roles.txt. - A shared versioned markdown document protected by a server-side mutex.
- Optimistic concurrency checks so stale writers are rejected instead of silently overwriting newer work.
- The server starts and prints its PID.
- A client sends
SIGUSR1to that PID to request a session. - The server creates
FIFO_C2S_<pid>andFIFO_S2C_<pid>, then signals the client withSIGUSR2. - The client sends its username over the private FIFO.
- The server authenticates the user from
roles.txt, returns the current document snapshot, and then accepts commands. - Each client is handled in its own detached thread, while document mutations are serialised with a mutex.
getinsert <pos> <text>delete <pos> <len>bold <start> <end>italic <start> <end>heading <level> <pos>newline <pos>
Users with read permission can connect and inspect the document. Users with write permission can edit it.
makeStart the server:
./server 2Connect as a writer and inspect the initial snapshot:
./client <server_pid> danielApply an edit:
./client <server_pid> daniel insert 0 "hello world"Fetch the latest state as a read-only user:
./client <server_pid> ryan getRun the end-to-end demo script:
make demoThis script exercises:
- signal-based handshake
- authenticated writer session
- authenticated reader session
- unauthorised-user rejection
- shared document visibility across clients
role:write
version:0
length:0
role:write
version:1
length:11
hello world
- It demonstrates real multi-client coordination rather than a single shared demo FIFO.
- The server protects the shared document with synchronisation instead of hoping requests arrive one at a time.
- Version checks make concurrency behavior visible.
source/server.c: handshake, session setup, authentication, per-client threads, request processing.source/client.c: handshake client, request formatting, snapshot decoding.source/markdown.c: document operations and version management.roles.txt: user permissions.