Question: Task 1 : Lets Do Some Calculation ! ! ! ! Client - Server Calculator [ 3 0 Points ] In this task, you need
Task : Lets Do Some Calculation ClientServer Calculator Points
In this task, you need to implement a clientserver based calculator. The client can submit any number
of queries ie mathematical expressions to the server. The server will evaluate the client's queries
one by one and send back the answer as a response.
In this task, the main process will call fork to create a child process where child process acts as the
server and the parent main process acts as client. The server will respond to all queries submitted by
the client until it receives a specific terminating word mentioned below as a query from the client.
After receiving the specific terminating word, the server will close the communication channel and
exits. You need to use pipe to establish a communication channel between client and server.
Figure : Workflow of clientserver based calculator.Figure shows the workflow of this clientserver based calculator using pipes. The client parent
should read expression or may be terminating word from standard input device, and will display
result received from the server on standard output device as shown in the figure.
Requirement specifications for this task are as follows:
Input expression is always space separated, ie blank space between operand and operator.
Input expression always starts with an operand.
Input expression can have at most operands ie it can have at most operators
Operands in input expression may be an integer or floatdouble number.
Input expression can contain any combination of these five operators viz. i Addition ii
Subtraction iii Multiplication iv Division and modulo
When server performs calculation, it needs to follow BODMAS rule where division, multiplication
and modulo operators are at same precedence say precedence and addition and subtraction
are at precedence According to BODMAS, server should first perform precedence operations
followed by precedence operations. Among same precedence operations, server should perform
operation from left to right.
When client receives END word from STDIN, it should send a termination signal to the server to
terminate it properly.
On receiving the result of mathematical expressions from the server, client should print "RESULT:
"followed by result. As an example, if client receive from the server, then it should display
"RESULT: on STDOUT.
Example of Input & Output:
INPUT
OUTPUT RESULT:
INPUT
OUTPUT RESULT:
INPUT END
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
