A console-based chat application that enables real-time communication between multiple users over a local network. Built with C++ using object-oriented programming principles and designed for emergency situations when internet connectivity is unavailable.
This project was inspired by the internet shutdown during Bangladesh's quota reform movement in July-August 2024, when centralized communication systems became unavailable. LocalChat provides a decentralized solution that operates on local area networks without requiring internet connectivity.
- Real-time messaging between multiple clients on the same network
- Cross-platform compatibility (Linux and Windows)
- Multi-threaded server supporting concurrent client connections
- Enhanced console UI with color-coded messages and beautiful formatting
- User identification system with unique usernames
- Automatic message broadcasting to all connected clients
- Graceful connection handling with join/leave notifications
- Thread-safe operations with proper synchronization
- Emergency communication capability without internet dependency
LocalChat/
โโโ ChatServer.hpp # Server class declaration
โโโ ChatServer.cpp # Server implementation
โโโ ChatClient.hpp # Client class declaration
โโโ ChatClient.cpp # Client implementation
โโโ ConsoleUtils.hpp # Cross-platform console utilities and formatting
โโโ main_server.cpp # Server application entry point
โโโ main_client.cpp # Client application entry point
โโโ Makefile # Cross-platform build configuration
โโโ README.md # Project documentation
โโโ report.md # Detailed project report
โโโ Learning_and_Timeline.md # Development timeline and learning notes
sudo apt-get update
sudo apt-get install build-essential g++ make git- MinGW-w64 or Visual Studio with C++ support
- Git for Windows
- Windows 7 or higher
- Note: For best visual experience on Windows, use Windows Terminal or PowerShell instead of Command Prompt
- Clone the repository
git clone https://github.com/Owhab/LocalChat.git
cd LocalChat- Build the applications
# Build both server and client
make all
# Or build individually
make server
make client- Verify installation
# Check executables were created
ls -la server client # Linux
dir server.exe client.exe # WindowsWindows Users: If you see special characters instead of borders, try using Windows Terminal or PowerShell for better Unicode support.
- Open a terminal and navigate to the project directory
- Run the server:
./server # Linux
server.exe # Windows- The server will start on port 12345 and display connection status
- Open a new terminal for each client
- Run the client:
./client # Linux
client.exe # Windows- Enter the server's IP address (127.0.0.1 for local testing)
- Choose a unique username
- Start chatting!
- Send message: Type your message and press Enter
- Exit: Type
exitand press Enter - Clear screen: Type
clearand press Enter
Linux:
ip addr show
# Look for wlan0 (wireless) or eth0 (ethernet) interfaceWindows:
ipconfig
# Look for IPv4 Address under your network adapterLinux (Ubuntu):
sudo ufw allow 12345/tcp
sudo ufw statusWindows:
- Open Windows Defender Firewall
- Create new inbound rule for port 12345 (TCP)
- Allow the connection
- Build LocalChat on the client device
- Run the client application
- Enter the server's network IP address (e.g., 192.168.1.100)
- Choose a username and start chatting
- Server: Multi-threaded TCP server handling concurrent connections
- Client: Dual-threaded client with separate send/receive operations
- Protocol: TCP for reliable message delivery
- Threading: C++11 standard threading library with mutex synchronization
- ChatServer: Manages client connections and message broadcasting
- ChatClient: Handles server connection and message exchange
- ConsoleUtils: Cross-platform console formatting and color support
- Uses conditional compilation for Windows/Linux socket APIs
- Unified color system with ANSI codes (Linux) and Windows Console API
- Cross-platform threading with std::thread and std::mutex
# Test network connectivity
ping <server-ip>
# Check if server is listening
netstat -tuln | grep 12345 # Linux
netstat -an | findstr 12345 # Windows- Ensure G++ compiler supports C++11 or higher
- Verify all source files are present
- Check make utility is installed
- Verify firewall allows port 12345
- Ensure server is running before connecting clients
- Check network connectivity between devices
If you see strange characters instead of nice borders on Windows:
-
Use Windows Terminal (recommended):
- Download from Microsoft Store
- Better Unicode and color support
-
Use PowerShell instead of Command Prompt:
- Right-click Start button โ Windows PowerShell
-
Enable UTF-8 in Command Prompt:
chcp 65001
-
Alternative: The application automatically falls back to ASCII characters on Windows for compatibility
- Graphical User Interface (GUI)
- Private messaging capabilities
- File sharing functionality
- Message encryption for security
- User authentication system
- Message persistence and history
- Audio/video communication support
This project demonstrates:
- Network Programming: Socket programming with TCP/IP
- Concurrent Programming: Multi-threading and synchronization
- Cross-platform Development: Platform abstraction techniques
- Object-Oriented Design: Clean class architecture and encapsulation
- Emergency Communication: Practical solution for connectivity crises
Abdul Owhab
- Email: [email protected]
- Course: SDP-1 (Software Development Project - 1)
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by the need for resilient communication during the 2024 Bangladesh internet shutdown
- Built for educational purposes and emergency preparedness
- Thanks to the C++ community for excellent documentation and resources
Note: This project serves both as a functional emergency communication tool and an educational resource for understanding distributed systems and network programming concepts.