Multi-client chat application built with C++17, TCP/IP sockets, and multithreading
Cross-platform support for Windows (Winsock2) and Linux (POSIX sockets)
This project is a production-style multi-client TCP chat system developed in C++17 to demonstrate practical knowledge of:
- TCP/IP socket programming
- Client-server architecture
- Multithreading and concurrency
- Cross-platform systems development
- Structured logging and debugging
- Modular software design
Unlike a basic single-user socket demo, this project supports:
- Multiple clients connecting to one server
- Real-time message broadcasting
- Username-based join and leave notifications
- Thread-per-client communication handling
- Logging for easier debugging and observability
- Cross-platform support using:
- Winsock2 on Windows
- POSIX sockets on Linux/macOS
This makes the project much closer to a real-world networking/system software mini-build than a simple classroom implementation.
- Multi-client TCP chat server
- Real-time client-server communication
- Username-based session handling
/listcommand to display active users/quitcommand for graceful disconnect- Broadcast messaging across connected clients
- Timestamped logging to
.logfiles - Cross-platform socket abstraction
- Clean folder structure and modular code organization
- Build support via g++ and CMake
- GitHub Actions CI workflow
| Area | Technology |
|---|---|
| Language | C++17 |
| Networking | Winsock2 (Windows), POSIX sockets (Linux/macOS) |
| Concurrency | std::thread, std::mutex |
| Build | CMake, g++ |
| Logging | File-based timestamped logs |
| Platform | Windows, Linux, macOS |
+------------------+ TCP Connection +------------------+
| Client 1 | -------------------------> | |
| (chat_client) | | |
+------------------+ | |
| |
+------------------+ TCP Connection | Chat Server |
| Client 2 | -------------------------> | (chat_server) |
| (chat_client) | | |
+------------------+ | |
| |
+------------------+ TCP Connection | |
| Client N | -------------------------> | |
| (chat_client) | +------------------+
+------------------+
server_main.cppstarts the server on a configurable port.chat_server.cppmanages connections, receives messages, and broadcasts them.client_main.cppstarts a client with host, port, and username.chat_client.cpphandles sending input and receiving server messages concurrently.platform.hppprovides cross-platform socket compatibility.logger.cppwrites timestamped logs for debugging and tracking activity.
cpp-tcp-socket-chat/
├── include/
│ ├── platform.hpp
│ ├── chat_server.hpp
│ ├── chat_client.hpp
│ ├── logger.hpp
│ └── utils.hpp
├── src/
│ ├── server_main.cpp
│ ├── client_main.cpp
│ ├── chat_server.cpp
│ ├── chat_client.cpp
│ ├── logger.cpp
│ └── utils.cpp
├── screenshots/
│ ├── 1socket.png
│ ├── 2socket.png
│ └── 3socket.png
├── .github/
│ └── workflows/
│ └── ci.yml
├── CMakeLists.txt
└── README.mdg++ -std=c++17 -Iinclude src/server_main.cpp src/chat_server.cpp src/logger.cpp src/utils.cpp -o chat_server.exe -lws2_32 -pthread
g++ -std=c++17 -Iinclude src/client_main.cpp src/chat_client.cpp src/logger.cpp src/utils.cpp -o chat_client.exe -lws2_32 -pthreadg++ -std=c++17 -Iinclude src/server_main.cpp src/chat_server.cpp src/logger.cpp src/utils.cpp -o chat_server -pthread
g++ -std=c++17 -Iinclude src/client_main.cpp src/chat_client.cpp src/logger.cpp src/utils.cpp -o chat_client -pthread.\chat_server.exe 9090.\chat_client.exe 127.0.0.1 9090 smeet.\chat_client.exe 127.0.0.1 9090 guest2| Command | Description |
|---|---|
/list |
Shows currently connected users |
/quit |
Gracefully disconnects from the chat |
| any text | Sends a broadcast message to connected clients |
Starting Chat Server on port 9090...
[2026-05-23 14:47:21] [INFO ] Server listening on port 9090
[2026-05-23 14:47:21] [INFO ] Waiting for clients...
[2026-05-23 14:47:44] [INFO ] New connection from 127.0.0.1
[2026-05-23 14:47:44] [INFO ] smeet joined from 127.0.0.1
[2026-05-23 14:48:05] [INFO ] New connection from 127.0.0.1
[2026-05-23 14:48:05] [INFO ] guest2 joined from 127.0.0.1[2026-05-23 14:47:44] [INFO ] Connected to 127.0.0.1:9090 as smeet
=== Connected as [smeet] ===
Commands: /list /quit or type any message
[server] Welcome, smeet!
[server] guest2 joined from 127.0.0.1[2026-05-23 14:48:05] [INFO ] Connected to 127.0.0.1:9090 as guest2
=== Connected as [guest2] ===
Commands: /list /quit or type any message
[server] Welcome, guest2!This project demonstrates:
- Socket programming using TCP
- Systems-level C++ development
- Cross-platform networking compatibility
- Concurrent client handling
- Practical debugging through logs
- Reusable modular code structure
- Command-driven terminal application design
- Private messaging with
/msg <username> <message> - File transfer between clients
- Persistent chat history
- User authentication
- Dockerized execution
- Event-driven scalability using
select()orepoll - Unit and integration test coverage
Smeet Patel
- GitHub: smeetpatel2530
- LinkedIn: Smeet Patel
This project is open for learning and portfolio use.


