A backend Java project featuring a suite of three TCP/IP server applications, demonstrating progression in socket programming, multi-threading, and remote file management.
This project focuses on building robust client-server architectures using Java. The main objective is to handle multiple client connections simultaneously without blocking the main server thread, ensuring a smooth and responsive network application. The repository includes three distinct server programs, culminating in a fully functional remote file server with state-based authentication.
The repository is structured around three server implementations, each adding a layer of complexity:
- Foundation: Upgrades a standard sequential server to a concurrent architecture.
- Thread-per-client: Uses Java's
Threadclass andRunnableinterfaces to spawn a new thread for every incoming connection, allowing multiple clients to interact with the server simultaneously without bottlenecks.
- Complex I/O: Builds upon the basic concurrent model to handle more complex data processing and continuous client-server message exchange.
- Resource Management: Ensures sockets and streams are properly managed and closed across multiple active threads to prevent resource leaks.
- Authentication System: The flagship implementation. The server requires a valid username and password session (e.g.,
javier/secreta) before granting access to its features. - State Machine Logic: Operates on a strict state diagram (Waiting for Connection -> Authenticating -> Ready for Commands -> Disconnected) to ensure secure request handling.
- Remote File System Access: Once authenticated, clients can interact with the server's filesystem to:
- List: View the contents of the server's current directory.
- Read: Request and display the contents of a specific file over the network.
- Exit: Gracefully terminate the session.
-
Clone the repository:
git clone [https://github.com/carlopezc/Java-Concurrent-Servers.git](https://github.com/carlopezc/Java-Concurrent-Servers.git) cd Java-Concurrent-Servers -
Compile the
.javafiles (replaceprogram3with the actual folder name):javac src/program3/*.java -
Start the Server in one terminal:
java -cp src program3.ServerMain
-
Start one or more Clients in separate terminals to test concurrency:
java -cp src program3.ClientMain