Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In this project, you are required to implement a network application, which cons

ID: 3715300 • Letter: I

Question

In this project, you are required to implement a network application, which consists of a server and one or more clients. The server will provide simple calculation services to the client(s). You should use both UDP sockets and TCP sockets to implement the communications between the server and the client(s).

Behavior on the client side:

The client program should be able to run in a forever while loop, so that the user can send as many calculation requests as he/she wants. The client program should provide two choices for the user: 1.) terminate the program, indicating that the user no longer needs to do any calculation this time. 2.) continue to input math expressions. The math expression is input as a string. You need to send the calculation request to the Simple Calculator Server using UDP socket and TCP socket. In this aspect, the message sending process is very similar to the example application we discussed in class.

Behavior on the server side:

The server should have a while loop that can continuously accept calculation requests. Server should understand at least the four operators, i.e., +, -, *, and /, when they appear alone. The result of a calculation request will be sent back to the corresponding requester as a string, which represents a number.

Four pieces of code are required: 1) UDP server code, 2) UDP client code, 3) TCP server code, 4) TCP client code. If you implement multi-threading in TCP, you should have at least one additional piece of code, i.e., TCP multithreaded server code.

Explanation / Answer

ANS:-

Given that,

Java Socket Programming

Java Socket writing computer programs is utilized for correspondence between the applications running on various JRE.

Java Socket programming can be association arranged or association less.

Attachment and ServerSocket classes are utilized for association arranged attachment programming and DatagramSocket and DatagramPacket classes are utilized for association less attachment programming.

The customer in attachment programming must know two data:

IP Address of Server, and

Port number.

Attachment class

An attachment is basically an endpoint for interchanges between the machines. The Socket class can be utilized to make an attachment.

Essential techniques

Method

1) open InputStream getInputStream()  

returns the InputStream connected with this attachment.

2) open OutputStream getOutputStream()  

returns the OutputStream connected with this attachment.

3) open synchronized void close()  

closes this attachment

ServerSocket class

The ServerSocket class can be utilized to make a server attachment. This protest is utilized to set up correspondence with the customers.

Essential techniques

Method

1) open Socket accept()

   returns the attachment and build up an association amongst server and customer.

2) open synchronized void close()  

closes the server attachment.

Program

File: MyClient.java

Case of Java Socket Programming (Read-Write both side)

In this illustration, customer will compose first to the server then server will get and print the content. At that point server will keep in touch with the customer and customer will get and print the content. The progression goes on.

File: MyServer.java

File: MyClient.java

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote