Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lfmramos/tool-concurrent-chat-server
https://github.com/lfmramos/tool-concurrent-chat-server
Last synced: 1 day ago
JSON representation
- Host: GitHub
- URL: https://github.com/lfmramos/tool-concurrent-chat-server
- Owner: lfmramos
- Created: 2024-11-09T10:03:55.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2024-11-09T10:48:12.000Z (2 months ago)
- Last Synced: 2024-11-09T11:29:15.436Z (2 months ago)
- Language: Java
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Java Multi-threaded Chat Server
A robust, multi-threaded chat server implementation in Java that allows multiple clients to connect and communicate in real-time. The server supports both broadcast and private messaging capabilities, with a thread pool architecture for efficient client handling.
## Features
- Multi-client support using thread pool architecture
- Real-time message broadcasting
- Private messaging between users
- User management (username changes, listing connected users)
- Command-based interface
- Graceful shutdown handling## Technical Architecture
The application consists of three main components:
1. **Main**: Entry point of the application that initializes and starts the server
2. **Server**: Manages incoming connections and maintains the thread pool
3. **ServerWorker**: Handles individual client connections and message processing### Server Configuration
- Default Port: 8080
- Thread Pool Size: 10 concurrent connections
- Connection handling: Non-blocking using Java NIO## Available Commands
Users can interact with the server using the following commands:
- `/w ` - Send a private message to a specific user
- `/h` - Display help menu with available commands
- `/c` - Change username
- `/l` - List all connected users
- `/q` - Quit the chat server## Getting Started
### Prerequisites
- Java Development Kit (JDK) 8 or higher
- Java IDE (recommended: IntelliJ IDEA or Eclipse)### Running the Server
1. Compile the Java files:
```bash
javac io/codeforall/fanstatics/*.java
```2. Run the server:
```bash
java io.codeforall.fanstatics.Main
```The server will start and listen for connections on port 8080.
### Connecting to the Server
Clients can connect to the server using any TCP client (such as Telnet or a custom client application):
```bash
telnet localhost 8080
```## Implementation Details
### Thread Safety
The server implements several thread-safety measures:
- Synchronized access to the shared client list
- Thread pool management for controlled resource usage
- Proper connection cleanup on client disconnect### Error Handling
The implementation includes:
- Graceful shutdown procedures
- Connection error handling
- Runtime exception management
- Resource cleanup in case of failures## Contributing
Feel free to submit issues and enhancement requests!
## Future Enhancements
Potential improvements that could be added:
1. SSL/TLS support for secure communications
2. Persistent chat history
3. User authentication
4. Custom room creation
5. File sharing capabilities