A real-time multi-client chat application built with C++ using sockets. Features include private messaging, timestamps, and user management.
- Real-time messaging: Broadcast messages to all connected clients
- Private messaging: Send direct messages using
/msg <username> <message> - Timestamps: All messages include timestamps in HH:MM format
- User management: Unique usernames, join/leave notifications
- Commands:
/helpto see available commands - Input validation: Prevents empty or duplicate usernames
- Error handling: Robust handling of network errors and disconnections
chat-app/
├── server/
│ ├── src/
│ │ └── server.cpp
│ ├── include/
│ │ └── server.h
│ └── Makefile
├── client/
│ ├── client.cpp
│ ├── include/
│ │ └── client.h
│ └── Makefile
└── README.md
- C++11 compatible compiler (g++)
- Linux/Unix environment with socket support
cd server
makecd client
make-
Start the server:
./server/server
-
Start clients in separate terminals:
./client/client
-
Enter a unique username when prompted
-
Start chatting! Use
/msg username messagefor private messages.
/msg <username> <message>- Send private message/help- Show available commandsexit- Quit the client
- Server: Multi-threaded server handling multiple clients concurrently
- Client: Single-threaded client with separate thread for receiving messages
- Protocol: Simple text-based protocol over TCP
- Threading: Uses C++11 threads and mutexes for synchronization
- Networking: POSIX sockets for cross-platform compatibility
- User authentication
- Message history
- File sharing
- GUI interface
- Encryption
- Admin commands
This project is open source and available under the MIT License.