Project 3: Unix Domain Socket Chat

Build a local IPC chat server using Unix domain sockets.

Quick Reference

Attribute Value
Difficulty Advanced
Time Estimate 1 week
Language C (Alternatives: Rust)
Prerequisites sockets, fork/exec
Key Topics IPC, sockets, multiplexing

1. Learning Objectives

By completing this project, you will:

  1. Create AF_UNIX sockets correctly.
  2. Accept and track multiple clients.
  3. Broadcast messages to all connected clients.
  4. Handle disconnects and cleanup safely.
  5. Understand tmux client-server communication basics.

2. Theoretical Foundation

2.1 Core Concepts

  • Unix Domain Sockets: Local IPC mechanism with file path addressing.
  • Server Loop: accept connections and multiplex client I/O.
  • Framing: Messages need boundaries to avoid partial reads.

2.2 Why This Matters

tmux clients connect to a server over a Unix socket. This project teaches the IPC layer.


3. Project Specification

3.1 What You Will Build

A server that accepts clients and relays messages, plus a simple client binary.

3.5 Real World Outcome

You can run two clients and see messages relayed instantly.


4. Solution Architecture

Client <-> Unix socket <-> Server <-> Client

12. Submission / Completion Criteria

Minimum Viable Completion:

  • Two clients can exchange messages