Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Simple Calculation Services via Network In this project, you are required to implement a network application, which consists of a server and one or more

Simple Calculation Services via Network

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 can input a math expression that it wants to calculate, such as 50 + 100, 50 * 100, etc.

In each iteration of the while loop, 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. This is like providing a menu for the user. You dont need to design Graphic User Interface (GUI). The client program can just print out some instructions for the user, and determine what the user wants according to the users input.

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.

If the user explicitly indicates that he/she wants to exit the program, the program should properly close any socket previously used for communications.

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. Expressions are received as strings. Example expressions: 40 + 50, 20 - 100, 10 * 20, 100/ 1000. It should be flexible enough such that if the expressions are reasonable, they should be considered valid and accepted. For example, these expressions: 40+50 , 40 + 50 , and 40+50, are all valid and should be accepted. That is, adding or removing arbitrary spaces anywhere in the expression shouldnt be a problem.

The result of a calculation request will be sent back to the corresponding requester as a string, which represents a number.

The server should be able to serve multiple clients, at least one client by one client.

Additional Remarks:

You are required to implement both the UDP version and the TCP version, without multithreading features. If you do not use multithreading, the UDP version can actually serve multiple clients in a semi-concurrent fashion; the server will respond the result to the corresponding request according to which client the request comes from; although all the calculations are done one by one. However, the TCP version cannot serve the clients concurrently, if you do not use multi-threading. A follow-up client will be served by the server only after the former client is done with the server, since the server only has one serial thread. Thus, to support true concurrent service in TCP, you can use multiple threads.

You need to write your function for evaluating a math expression. Do not use existing libraries, write your own. Its OK to support the basic expressions (with two operands, one operator, and arbitrary operators). You receive 2 bonus points for supporting two different operators in the same expression. You receive 3 bonus points for supporting four different operators in the same expression.

You should demonstrate how you run your program in class in the project presentation. Its OK to run the client and server programs on the same machine (the localhost). You receive 2 bonus points for demonstrating your programs on 2 virtual machines (within Virtual Box or VMWare). You receive 3 bonus points for demonstrating your programs on two different physical machines, such as two different laptops.

You are required to implement two version of the project: using UDP sockets and using TCP sockets. Its OK to not implement multithreading to support multiple clients concurrently. You receive 12 bonus points if you can implement a multi-threading version for your TCP implementation. Multi-threading is also possible for the UDP implementation; but it is not recommended for this project.

The presentation should have some slides showing your work, such as your design, the features that your project supports, and a demonstration of how to run your programs.

Your need to write a formal project report, which consists of the following components:

Your project report should have at least 3 pages (with font size smaller than or equal to 11 point).

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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Fill out the following table for substance ammonia

Answered: 1 week ago