Multi-Client TCP Chat System

A multithreaded TCP chat server and client in C++ with Winsock2, supporting broadcast and private messaging with real-time presence

Technology Stack
C++
Winsock2
Multithreading
TCP/IP

Project Overview

A multithreaded TCP chat server and client written in C++ with Winsock2. The server dedicates a thread per connection and synchronizes shared state with mutexes to safely support many concurrent sessions, offering broadcast and private messaging with real-time presence notifications.

Key Features

  • • Thread-per-connection server architecture for concurrent client sessions
  • • Shared state synchronized with CRITICAL_SECTION mutexes to prevent race conditions across concurrent sessions
  • • Broadcast and private messaging with real-time presence notifications
  • • Persistent user accounts via thread-safe file I/O
  • • Authentication and input validation enforced before command dispatch

Technical Approach

  • • Low-level socket programming with the Winsock2 API
  • • Per-connection threading with explicit mutex-guarded critical sections
  • • Command-based protocol with server-side validation and authentication
  • • Thread-safe persistence of user accounts to disk

Results & Insights

Performance

Successfully implemmented a multithreaded TCP chat system capable of handling multiple concurrent clients with real-time messaging and presence notifications. The use of mutexes ensured thread safety and prevented race conditions, resulting in a stable and responsive application.

Development Insights

This was a long term project for my Computer Networks course, and it provided valuable experience in low-level network programming, multithreading, and synchronization techniques.

1 / Client

Dedicated Thread per Connection

2

Messaging Modes (Broadcast & Private)