A real-time chat application implemented using Java Socket Programming, enabling multiple clients to connect to a centralized server and communicate with each other.
- Multi-client support: Connect multiple users simultaneously
- Real-time messaging: Instant message delivery between clients
- Threaded architecture: Each client connection is handled in a separate thread
- User notifications: Alerts when users join or leave the chat
- Simple and intuitive interface: Easy-to-use command-line interface
- Robust error handling: Graceful management of unexpected disconnections
- Java JDK 8 or higher
- Basic understanding of networking concepts
-
Clone the repository:
git clone https://github.com/ChamathDilshanC/Multi-Client-Chat-Application.git cd Multi-Client-Chat-Application
-
Compile the source code:
javac *.java
-
Start the server:
java Server
-
Launch the client(s) in separate terminal windows:
java Client
-
Follow the on-screen instructions to join the chat.
The application follows a client-server architecture:
┌─────────┐
│ Server │
└────┬────┘
│
┌───────────┴───────────┐
│ │ │
┌────▼─────┐ ┌────▼─────┐ ┌────▼─────┐
│ Client 1 │ │ Client 2 │ │ Client 3 │
└──────────┘ └──────────┘ └──────────┘
- Server: Manages client connections and routes messages between clients
- Client: Connects to the server and provides a user interface for sending/receiving messages
ServerSocket
: Listens for incoming client connectionsClientHandler
: Manages individual client connections (implemented as threads)- Message broadcasting system to relay messages to all connected clients
Socket
: Establishes connection with the server- Input handling for user messages
- Output handling for displaying received messages
Once the server is running, it will display connection information and wait for clients to connect.
After starting a client:
- Enter a username when prompted
- Start typing messages to communicate with other connected users
- Use the
/quit
command to exit the chat
- Currently only supports local network connections
- No message persistence (history is lost when the server restarts)
- No private messaging between specific users
Future enhancements planned:
- Add user authentication
- Implement private messaging
- Create a graphical user interface
- Add message persistence
- Enable file sharing between users
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Chamath Dilshan - @ChamathDilshanC
Project Link: https://github.com/ChamathDilshanC/Multi-Client-Chat-Application
- Java Socket Programming Documentation
- All contributors who have helped improve this project