Cross Platform Java server and Client using sockets
Explore the docs »
Report Bug
·
Request Feature
This Project consists of two parts:
-
Server: Having two functions:
- Checking if a string is a palindrome
- Reversing a string
-
Client: Connects to the server, sends requests, and displays results.
- Configurable Network Settings
- Multithreaded server
- Input Validation
- Error Handling
- Isolated client handling failures (one client error won't affect other clients)
- Clean code
- Java Development Kit (JDK) 8 or higher
- IntelliJ IDEA IDE (recommended)
The server listens for client connections and processes string manipulation requests.
Featuring:
-
Configurable Port:
- The user can choose to use the default port (8888) or specify a custom port (1024-65535).
- Validates user input to ensure the port is within valid range.
-
Multithreaded Architecture:
- Each client connection is handled in a separate thread by the
ClientHandler
class. - Allows the server to handle multiple clients simultaneously without blocking.
- Each client connection is handled in a separate thread by the
-
Network Information Display:
- Shows the server's IP address when started, making it easier for clients whom are on different machine to connect. Note: If the client and the server are on the same machine, use localhost or any loopback IP address actually (127.0.0.0/8)
-
String Manipulation Functions:
- Palindrome Check: Checks if a string reads the same backward as forward.
- Returns "1" for palindromes, "0" for non-palindromes.
- Ignores spaces and isn't case-sensitive for easier use.
- String Reversal: Reverses the input string.
- Uses Java's StringBuilder for efficient string manipulation.
- Palindrome Check: Checks if a string reads the same backward as forward.
-
Error Handling:
- Socket binding errors
- Connection acceptance errors (ex: if the port is already in use or if there are firewall restrictions)
- Client communication errors
- Invalid input handling
- The server starts and prompts for port configuration.
- After binding to the port, it displays its IP address and waits for client connections.
- When a client connects, a new thread is created to handle that client.
- The handler thread:
- Reads the function choice (1 or 2)
- Reads the input string
- Processes the request based on the choice
- Sends the result back to the client
- Closes the connection
- The main server thread continues listening for new connections.
The client connects to the server, sends requests and displays results.
Featuring:
-
Configurable Connection Settings:
- Server Address: Use localhost (default) or specify a custom IP address.
- Server Port: Use default port (5555) or specify a custom port.
-
User Interaction:
- Clear and formatted output of results.
-
Operation Modes:
- Palindrome Check: Displays whether the string is a palindrome.
- String Reversal: Shows the reversed string.
-
Error Handling:
- Connection failures
- Invalid server address
- Invalid port numbers
- Server communication errors
- Input validation
String Operations Server Setup
-----------------------------
Use default port (5555)? (Y/n): y
Server started on port 8888
Server IP address: 192.168.57.1
Waiting for clients...
Client connected: 127.0.0.1
Client disconnected
String Operations Client
------------------------
Server connection setup:
Use localhost (default)? (Y/n): n
Enter server IP address: 127.0.0.1
Use default port (5555)? (Y/n): y
Connecting to server at 127.0.0.1:5555...
Connected to server.
Choose an operation:
1. Check if a string is a palindrome
2. Reverse a string
Enter your choice (1 or 2): 1
Enter a string: Ahmed
Result: "Ahmed" is not a palindrome.
Project's Link: https://github.com/ahmeddwalid/DSSsockets
Any contributions you make are greatly appreciated.
Features to be implemented:
-
Security:
- Adding authentication for client connections
- Implementing encryption for data transmission
- Adding server system logs
-
User Interface: A long stretch but a GUI possibly?
If you'd like to contribute, please follow these steps:
- Fork the repository: Create your own copy of the project.
- Create a branch:
git checkout -b feature/your-feature-name
- Make your changes: Implement your contribution.
- Commit your changes:
git commit -m "Add your descriptive commit message"
- Push to the branch:
git push origin feature/your-feature-name
- Create a pull request: Submit your changes for review.
- Write clear and concise commit messages.
- Provide detailed explanations in your pull requests.
- Be respectful and considerate of other contributors.
Thank you for your contributions!
This project is distributed under the Apache 2.0 license. See
LICENSE.txt
for more information.