Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CODE IN PYTHON (SCRREN SHOOT RESULT) Math Service via Network You are required to implement a math server and a math client. The behaviors of

CODE IN PYTHON (SCRREN SHOOT RESULT)

Math Service via Network

You are required to implement a math server and a math client. The behaviors of the clients and server in

this project are similar to that of the clients and server in Project 1. The client should allow the user to

continuously issue requests until the user inputs Quit. The differences are:

Users will input some math expression, such as 2 + 3, 2 *3 , 2 + 3 * 4/5, etc., in the client.

The client will send the math expression to the server.

The server will evaluate the result of the received math expression, and send back the final result

back to the requesting client. The result should be sent back as a string. For example, if the server

receives 2 + 3, it will send back 5. If the server receives 2 *3 , it will send back 6.

Basically, instead of sending strings and receiving capitalized strings, the client will send math expressions

and receive the results of the math expressions. You can tell that this project is not very different from

the Project 1. You can potentially reuse some part of your original code.

On the server side, you need some evaluation function to evaluate a math expression. You can implement

your own, or you can use some existing library functions/methods. In either case, your server should

support valid math expressions that involve the four basic operators: +, -, *, and /. The math

expressions can have arbitrary number of spaces/tabs within them, and they should still be regarded as

valid.

Requirements:

1. You are required to implement the

UDP

version. The UDP server should be able to serve multiple

clients at the same time by default, without multi-threading.

2. You are required to implement the

TCP non-persistent

version. The TCP non-persistent server

should be able to serve multiple clients at the same time by default, without multi-threading.

3. You are required to implement the

TCP persistent version without multi-threading

. The TCP

persistent server should be able to serve multiple clients, not necessarily at the same time. That

is, the server should be able to serve one client, and have several other clients pending while it is

serving the first client. When the first client is done (quit gracefully), the server can pick up the

next pending client and serve it; after this client is done, the server can again pick up the next

pending client ant serve it.

4. You are required to submit a

project report

. In your project report, you should include

comprehensive tests to demonstrate that all your programs meet the requirements. For example,

for the UDP version, your testing should show that your server really can serve multiple clients at

the same time. You can include a screenshot with multiple clients concurrently running and

getting the service. Also, show that when a client gracefully quits (by issuing Quit), other clients

can still get the service without a problem, and new clients can come to get the service without a

problem. The project report will have a large weight in terms of grading.

5. You are highly recommended to implement the

TCP persistent version with multi-threading

,

because you are required to implement multi-threading for the group project anyways. The multi-

CSIT 340 Computer Networks

threaded TCP persistent server can serve multiple clients at the same time. You receive 4 bonus

points for implementing the TCP persistent version with multi-threading.

You can implement the project in any programming language you like. Examples on how to implement

multi-threading can be found in the projects folder of Canvas Files:

Java:

MultiThreadDemo.java

and

MultiThreadDemo2.java

Python:

multithread.py

and

multithread2.py

Submission:

7 files are required:

1. UDPMathServer.java/UDPMathServer.py

2. UDPMathClient.java/UDPMathClient.py

3. TCPNonPersistentMathServer.java/TCPNonPersistentMathServer.py

4. TCPNonPersistentMathClient.java/TCPNonPersistentMathClient.py

5. TCPPersistentMathServer.java/TCPPersistentMathServer.py

6. TCPPersistentMathClient.java/TCPPersistentMathClient.py

7. Project Report

If you implement the TCP persistent version with multi-threading, you should submit one additional file:

TCPPersistentMathServerMultithread.java/ TCPPersistentMathServerMultithread.py

The code in TCPPersistentMathClient.java/TCPPersistentMathClient.py should be able to work with

the multi-threaded server without any modification. You should also include tests for the multi-threaded

server in your project report, if you implement it.

Related Resources:

Python 2 multithreading:

http://www.techbeamers.com/python-multithreading-concepts/

https://www.tutorialspoint.com/python/python_multithreading.htm

Python 3 multithreading:

https://www.tutorialspoint.com/python3/python_multithreading.htm

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: 3

blur-text-image

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

Database Systems Design Implementation And Management

Authors: Peter Rob, Carlos Coronel

6th International Edition

061921323X, 978-0619213237

More Books

Students also viewed these Databases questions