Write a client-server program the server has the following


Question 1 -

Write a client-server program. The server has the following properties:

  • It wait for requests at port 12345.
  • It will create a thread to serve one incoming request.
  • In each request, an integer is sent from the client. Then, the server will send back the average of all the numbers that have been sent to the server. The average should be of type double.
  • Since the server is multithreaded, make sure that your system is thread safe.
  • You should also write a client so that the user can send in a number and display the current average.

The client should look like this:

2152_Figure.png

The first text field is used to set the IP address of the server. The second text field is used to input an integer. The connection is created when the button is pressed. The bottom line shows the current average held by the server.

Question 2 -

Rewrite question 1 as a Web service. The client should look the same as that in question 1.

Please note that the host field in the client should have no use as the client is tied to a server when you wrote the client. Therefore the client is not free to choose the server. So in the client, you just ignore the contents in the Host field.

Question 3 -

Rewrite the server of question 1 but use a database to store the information from clients instead of attributes.  For example, you may have attributes in your answer to question 1 to store the total sum of integers and number of requests so far.  However, in this question, you should use a database to store them.

In your answer, in addition to the Java program code, you should also give the SQL statements to create your database.

You do not need to rewrite the client in Question 1.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Write a client-server program the server has the following
Reference No:- TGS01594274

Expected delivery within 24 Hours