This system consists of a server and multiple client processes. Each client process will connect to the server over a socket connection and register a user name at the server. The server and the client are managed with a simple GUI. The messages exchanged between server and client use HTTP format.
The actions performed by the client and server are summarized below -
The client will execute the following sequence of steps:
- Connect to the server via a socket.
- Provide the server with a unique user name (Some value associated with the process)
- Generate a random integer between 5 and 15.
- Upload that integer to the server.
- Wait until response received from the server.
- Parse the HTTP message and print response from the server in normal text.
- Repeat at step 3 until the process is killed by the user.
The server concurrently supports all the connected clients and displays a list of them in real-time. The server will execute the following sequence of steps:
- Startup and listen for incoming connections.
- Print that a client has connected and fork a thread to handle that client.
- Print integer received from client to GUI and announce that it is waiting for that period of time.
- Sleep for the number of seconds equal to that integer.
- After waiting, will return a message to client stating, “Server waited <#> seconds for client .”
- Begin at step 3 until connection is closed by the client.
- When a client gets disconnected, the user is notified in real-time.
- Print all the incoming and outgoing messages in unparsed HTTP format.
ServerGUI
extendsjavafx.application.Application
HTTPServer
extendsjava.lang.Thread
ServerThread
extendsjava.lang.Thread
ClientGUI
extendsjavafx.application.Application
Client
extendsjava.lang.Thread
javac HTTPServer.java
javac ServerGUI.java
javac ClientGUI.java
java ServerGUI
java ClientGUI
- JavaFX: Working with the JavaFX Scene Graph – https://docs.oracle.com/javase/8/javafx/scene-graph-tutorial/scenegraph.htm
- HTTP Made Really Easy - A Practical Guide to Writing Clients and Servers – https://www.jmarshall.com/easy/http/
- Introducing Threads in Socket Programming in Java – https://www.geeksforgeeks.org/introducing-threads-socket-programming-java/
This code was submitted as part of Distributed Systems course assignment at The University of Texas at Arlington to Prof. Chance Eary (https://mentis.uta.edu/explore/profile/chance-eary)