Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Develop two Python scripts: one a server; the other a client that will use the server. You will use the polynomial function module polynomials.py. Do

Develop two Python scripts: one a server; the other a client that will use the server. You will use the polynomial function module polynomials.py. Do not include those functions directly into your server code, but import them into the server (see Additional Notes below).

Server (5 points)

The server will listen on a specific port number (ex. 12345). It will carry out polynomial computations using the functions in the provided module. Requests are in one of two formats:

Evaluate Request

Request starts with E

Followed by an argument value

Followed by a single space

Followed by the coefficients of a polynomial, separated by single spaces

Bisection Request

Requests starts with S

Followed by a, b, polynomial, tolerance separated by single spaces

For example, here is a sample evaluate request:

E1.0 -945 1689 -950 230 -25 1

This is a request to evaluate the polynomial -945 + 1689x - 950x2 + 230x3 - 25x4 + x5 at the value x = 1.0

Here is a sample bisection request:

S0 2 -945 1689 -950 230 -25 1 1e-15

This requests the use of the bisection function with a = 0, b = 2, tolerance = 1e-15 and using the same polynomial as in the evaluate example.

The server will create a response to the client for each request. The first character of the response will indicate the type of response:

X indicates an error response. The remainder of the response is an error message

E indicates a successful response to an evaluate request. This is immediately followed by the value returned by the evaluate function

S indicates a successful response to a bisection request. This is immediately followed by the value returned by the bisection function

The response to the example evaluate request would be2

E2.2737367544323206e-13

The response to the example bisection request would be

S1.0000000000000004

The server should operate in a continuing manner: the server should repeatedly accept a connection, get a request, send a response and close the connection to the client. In particular, only one request is handled for each connection.

Server Error Checking (2 points)

The server should respond properly in the case of an erroneous request. Not only should the server not crash but the server should send back an appropriate error response to the client.

For example, the request string

E1.0 -945xx 1689 -950 230 -25 1

should result in a response something like this:

Xinvalid format numeric data

Note the X that flags this as an error message.

Include error checking in the server. Also document the error checking by including a string at the end of the server code that describes the errors caught. That string might look something like this (to start with):

'''

Invalid numeric format

Wrong number of fields in request

'''

Client (3 points)

You are strongly urged to write small clients that will test aspects of your server as you work on that. Once you are satisfied that you can send an evaluation request and get a good result and also send a bisection request and get a good result then work on the client described here.

The client should define four variables at the beginning: the first, named poly with a list of numbers representing the coefficients of a polynomial;3 another, named a, representing a value a to use in bisection; another, named b representing a value b to use in bisection; another, named tol representing a tolerance value to use in bisection.

Note: in testing your client, the values assigned to these variables will be changed so make sure they are evident.

The client should first make a request to the server for a bisection. Provide the data defined in the variables just described. Display the value returned.

The result from the first request should be used as the x value in another request to the server to evaluate the polynomial (defined in the variable described above). The result of the evaluation should be displayed. This value should be very close to 0.

http://jmp.sh/v/qrGpHThGGJaj7HhpMW35 ( polynomials.py)

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

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions