Project 5: System V Message Queue Multi-Client Server
A server using System V message queues where clients multiplex on a single queue using message types.
Quick Reference
| Attribute | Value |
|---|---|
| Primary Language | C |
| Alternative Languages | N/A |
| Difficulty | Level 3 (Advanced) |
| Time Estimate | See main guide |
| Knowledge Area | IPC, Multiplexing |
| Tooling | See main guide |
| Prerequisites | See main guide |
What You Will Build
A server using System V message queues where clients multiplex on a single queue using message types.
Why It Matters
This project builds core skills that appear repeatedly in real-world systems and tooling.
Core Challenges
- ftok collisions → Understanding key generation
- Message type protocol → Designing the multiplexing scheme
- Cleanup on crash → Orphaned queues persist!
Key Concepts
- Map the project to core concepts before you code.
Real-World Outcome
# Server uses one queue for all clients
$ ./sysv_server
Server starting, key=0x12345678, msqid=100
Waiting for requests (msgtyp=1)...
# Client 1 (PID 5001) sends request
$ ./sysv_client "HELLO"
Sending to server (msgtyp=1)
Waiting for response (msgtyp=5001)
Response: HELLO_PROCESSED
# Client 2 (PID 5002) sends simultaneously
$ ./sysv_client "WORLD"
Response: WORLD_PROCESSED
# Both used the SAME queue, but different message types!
$ ipcs -q
------ Message Queues --------
key msqid owner perms used-bytes messages
0x12345678 100 user 644 0 0
Implementation Guide
- Reproduce the simplest happy-path scenario.
- Build the smallest working version of the core feature.
- Add input validation and error handling.
- Add instrumentation/logging to confirm behavior.
- Refactor into clean modules with tests.
Milestones
- Milestone 1: Minimal working program that runs end-to-end.
- Milestone 2: Correct outputs for typical inputs.
- Milestone 3: Robust handling of edge cases.
- Milestone 4: Clean structure and documented usage.
Validation Checklist
- Output matches the real-world outcome example
- Handles invalid inputs safely
- Provides clear errors and exit codes
- Repeatable results across runs
References
- Main guide:
UNIX_IPC_STEVENS_VOL2_MASTERY.md - Primary references are listed in the main guide