A high-performance, concurrent Chat Server and Client built in C for Linux. This project demonstrates core systems programming concepts including multi-threading, socket I/O, and inter-process synchronization.
- Concurrent Server: Handles multiple simultaneous client connections using
pthreads. - User Authentication: Secure registration and login system with persistent storage.
- Thread Safety: Uses
pthread_mutexto protect shared resources and global client lists. - File Integrity: Implements
flock(advisory locking) to prevent race conditions during database writes. - Modular Architecture: Clean separation of concerns between authentication, chat logic, and UI handlers.
- Graceful Shutdown: Handles
SIGINTandSIGTERMto clean up resources and close sockets properly.
- Language: C (Standard C99/C11)
- Networking: BSD Sockets (TCP/IP)
- Concurrency: POSIX Threads
- Build System: GNU Make
- OS: Linux (tested on Ubuntu/WSL)
.
βββ Makefile # Automated build script
βββ include/ # Header files (.h)
β βββ common.h # Shared structures and packet types
β βββ server.h # Server-side declarations
β βββ client.h # Client-side declarations
βββ src/ # Source files (.c)
β βββ server/ # Auth manager, chat logic, and main server loop
β βββ client/ # UI handlers and main client loop
βββ README.md