A robust multithreaded TCP web server in Java that efficiently manages multiple client connections with personalized responses.
- Introduction
- Features
- Technologies Used
- Getting Started
- Code Structure
- Usage
- Contributing
- Acknowledgments
The Multithreaded Web Server is a simple yet powerful TCP server written in Java, designed to handle multiple client connections simultaneously. It utilizes multithreading to ensure that each client is served in its own thread, providing a responsive and efficient user experience.
- Handles multiple clients using a thread pool.
- Each client receives a personalized greeting message.
- Graceful server shutdown to finish current connections.
- Configurable thread pool size for optimal performance.
- Java SE
- Socket Programming
- Multithreading
- ExecutorService
- Java Development Kit (JDK) 8 or higher
- An IDE or text editor (e.g., IntelliJ IDEA, Eclipse, Visual Studio Code)
- Clone the repository:
git clone https://github.com/yourusername/multithreaded-webserver.git cd multithreaded-webserver
- Compile the server and client:
javac Server.java Client.java
To start the server, navigate to the directory containing the compiled Server.class and run: java Server The server will start listening on port 8010. You can adjust the port in the Server class if needed.
To connect to the server, navigate to the directory containing the compiled Client.class and run: java Client You can modify the number of clients in the Client class to test the server's handling of multiple connections.
multithreaded-webserver/ └──> Server.java # Contains the server implementation └──> Client.java # Contains the client implementation
Start the server before running the client. Each client will connect to the server and receive a greeting message. Monitor the server console for connection logs.
Contributions are welcomed! Please follow these steps:
- Fork the repository.
- Create a new branch: bash: git checkout -b feature/YourFeature
- Make your changes and commit: bash: git commit -m "Add your feature"
- Push to the branch: bash: git push origin feature/YourFeature
- Create a pull request.
Inspired by examples of TCP servers and multithreading concepts in Java. Special thanks to online communities for their valuable resources and support.
This project is built by Me: Shobhit Singh