Java socket programming assignment for Distributed Systems.
It implements three network applications demonstrating client-server communication patterns,
multi-threading, and network application development using Java 17.
Simple utility program that converts hostnames to IP addresses using Java's InetAddress class.
Multithreaded server that responds with "pong" to "ping" messages while dropping other messages.
Client-server application where the server converts received messages to uppercase and returns them.
- Language: Java 17.0.14 LTS
- IDE: IntelliJ IDEA
- Operating System: Windows 10 (adaptable to other platforms)
- Libraries: Standard Java libraries (
java.net
,java.io
) - Character Encoding: UTF-8 for international support
socket-programming/
├── README.md # Main project documentation
├── .gitignore # Git ignore patterns
├── compile-all.bat # Compilation script
├── run-servers.bat # Server startup script
│
├── docs/ # Comprehensive documentation
│ ├── compilation-guide.md # Compilation and setup instructions
│ ├── troubleshooting.md # Common issues and solutions
│ ├── examples.md # Usage examples and scenarios
│ ├── code-quality-review.md # Code quality assessment
│ └── integration-analysis.md # Cross-task integration analysis
│
├── task1-hostname-converter/ # Task 1: DNS resolution
│ ├── src/
│ │ └── HostnameToIP.java # Main application class
│ └── docs/
│ ├── requirements.md # Task requirements
│ ├── design.md # Design documentation
│ └── UserGuide.md # User manual
│
├── task2-ping-pong/ # Task 2: Client-server communication
│ ├── src/
│ │ ├── server/
│ │ │ └── PingPongServer.java # Multi-threaded server
│ │ └── client/
│ │ └── PingPongClient.java # Interactive client
│ └── docs/
│ ├── architecture.md # System architecture
│ ├── protocol.md # Communication protocol
│ ├── client-usage.md # Client usage guide
│ ├── run-configurations.md # IDE configuration
│ └── usage.md # General usage guide
│
├── task3-uppercase-converter/ # Task 3: Text processing service
│ ├── src/
│ │ ├── server/
│ │ │ └── UppercaseServer.java # Production-quality server
│ │ └── client/
│ │ └── UppercaseClient.java # Feature-rich client
│ └── docs/
│ ├── design.md # Design documentation
│ └── workflow.md # Processing workflows
│
└── tests/ # Comprehensive testing
├── task1/
│ ├── TestCases.md # Test cases and results
│ ├── TestExecutionLog.md # Execution logs
│ └── PerformanceTest.md # Performance analysis
├── task2/
│ ├── IntegrationTestPlan.md # Integration testing
│ ├── TestExecutionLog.md # Test results
│ └── MultiClientTest.md # Multi-client testing
└── task3/
├── TestingPlan.md # Comprehensive test plan
├── TestExecutionLog.md # Detailed test results
└── PerformanceResults.md # Performance benchmarks
- Java 17.0.14 LTS or higher
- IntelliJ IDEA (recommended)
- Git for version control
- Windows 10 (instructions adaptable for other OS)
git clone https://github.com/NMsby/socket-programming.git
cd socket-programming
compile-all.bat
run-servers.bat
cd task1-hostname-converter
javac src/HostnameToIP.java
java -cp src HostnameToIP
# Terminal 1 - Server
cd task2-ping-pong
javac src/server/PingPongServer.java
java -cp src server.PingPongServer
# Terminal 2 - Client
javac src/client/PingPongClient.java
java -cp src client.PingPongClient
# Terminal 1 - Server
cd task3-uppercase-converter
javac src/server/UppercaseServer.java
java -cp src server.UppercaseServer
# Terminal 2 - Client
javac src/client/UppercaseClient.java
java -cp src client.UppercaseClient
Objective: Learn basic networking and DNS resolution
Features:
- Interactive hostname input and IP address resolution
- Support for IPv4 and IPv6 addresses
- Multiple IP address handling
- Comprehensive error handling
- Address type classification
Key Learning: DNS resolution, InetAddress
class, network error handling
Objective: Understand client-server architecture and protocols
Features:
- Multi-threaded TCP server supporting concurrent clients
- Case-insensitive ping detection with exact matching
- Message filtering (only "ping" receives "pong" response)
- Interactive client with automated testing
- Comprehensive connection management
Key Learning: TCP sockets, multi-threading, protocol design, resource management
Objective: Build production-quality network applications
Features:
- UTF-8 encoding for international character support
- Rich interactive client with comprehensive commands
- Detailed logging and monitoring capabilities
- Performance optimization and error recovery
- Configurable message length limits
Key Learning: Character encoding, production patterns, performance optimization
- Unit Testing: Individual component validation
- Integration Testing: Cross-component functionality
- Performance Testing: Response times and throughput
- Load Testing: Concurrent client handling
- Edge Case Testing: Error conditions and recovery
- Task 1: 100% success rate with comprehensive DNS testing
- Task 2: Multi-client support validated up to 50+ concurrent connections
- Task 3: International character support verified with UTF-8 encoding
- Overall: All performance targets exceeded with <10 ms average response times
Metric | Task 1 | Task 2 | Task 3 |
---|---|---|---|
Response Time | <100ms | <10ms | <10ms |
Concurrent Clients | N/A | 50+ | 50+ |
Throughput | N/A | 200+ msg/s | 200+ msg/s |
Memory Usage | <20MB | <40MB | <40MB |
Success Rate | 100% | 100% | 100% |
- Open Project: File → Open → Select project directory
- Configure SDK: Project Structure → Project → Set Java 17
- Build Project: Build → Build Project
- Run Configurations: Pre-configured for each task component
- Compilation Scripts:
compile-all.bat
for automated building - Server Management:
run-servers.bat
for concurrent server startup - Individual Compilation: Task-specific compilation commands
- Assignment Requirements: Overview of project goals and objectives
- Implementation Notes: Detailed implementation notes for each task
- Compilation Guide: Setup and building instructions
- Troubleshooting Guide: Common issues and solutions
- Usage Examples: Comprehensive usage scenarios
Each task includes detailed documentation covering:
- Requirements analysis and design decisions
- Architecture and implementation details
- Usage guides and examples
- Testing procedures and results
- Authentication and authorization
- TLS/SSL encryption support
- Load balancing capabilities
- Database integration
- REST API endpoints
- Web-based management interface
- Additional protocol implementations
- Performance monitoring dashboards
- Container deployment (Docker)
- Microservices architecture
- Message queuing systems
This is an academic project, but suggestions and improvements are welcome!
Nelson Masbayi
- Distributed Systems Assignment
- Java 17 Socket Programming Implementation
This project is licensed under the MIT License - see the LICENSE file for details.