Chatroom Application

chat

2026 · Solo project · C++20 on Linux, no GUI framework, no third-party libraries

A terminal-based, multi-user TCP chat server and client in modern C++20 for Linux. Everything from the length-prefixed wire protocol to the raw-mode line editor is built directly on POSIX sockets and termios. Multiple clients connect to a central server, pick a display name, and broadcast messages in real time, with join/leave/AFK notices and slash commands. The concurrency model is thread-per-connection, made race-free with shared_ptr connection ownership and per-socket write mutexes — verified clean under ThreadSanitizer.

Small in feature surface but rigorous in engineering: correct message framing over a TCP byte stream, RAII ownership of every file descriptor, a terminal UI where incoming messages never corrupt the line you’re typing, and sanitizer builds that caught and fixed two real concurrency bugs.


Learning outcomes

  • Application-level framing over a TCP byte stream: length-prefixed frames, looping recv/send past split/short I/O, explicit endianness, size caps.
  • A thread-per-connection server made correct: shared_ptr connection lifetime to defeat the fd-reuse race, snapshot-then-send broadcast for latency isolation, per-socket write mutex, and a leaked registry to avoid an exit-race.
  • Raw-terminal UX: termios non-canonical mode, a thread-safe redrawing line editor, and RAII/atexit restoration of the terminal on every exit path.