A calculator console app to utilize remote procedure calls implemented with Sun RPC (rpcgen)
This RPC program is compiled using Sun RPC (rpcbind)
sudo apt-get install rpcbind
rpcinfo
(rpcinfo command is for checking the installation)
rpcgen -a -C calc.x
make -f Makefile.calc
sudo ./calc_server
Open another Terminal and run sudo ./calc_client localhost [operations in postfix syntax]
sudo ./calc_client localhost 10 20 x
mul(10, 20) is called
Inserting 10
Inserting 20
Removing 20
Removing 10
Result: 200
Inserting 200
sudo ./calc_client localhost 10 20 x 35 - 44 +
mul(10, 20) is called
sub(200, 35) is called
add(165, 44) is called
Inserting 10
Inserting 20
Removing 20
Removing 10
Result: 200
Inserting 200
Inserting 35
Removing 35
Removing 200
Result: 165
Inserting 165
Inserting 44
Removing 44
Removing 165
Result: 209
Inserting 209
sudo ./calc_client localhost 10 20 asd
(nothing)
Inserting 10
Inserting 20
Please enter a valid input and try again.
sudo ./calc_client localhost 10
(nothing)
usage: ./calc_client server_host [expression without whitespace] [operation] [expression without whitespace]
Example 5 Call: (division with 0 handling. Handled in server since if it someone meddles with the client code and sends such a request to the server, the server crashes. Has to be on the server side. Divides with 1 instead.)
sudo ./calc_client localhost 10 0 /
You have tried a zero division. Do not trust the output (it's divided by 1) and please don't try to divide something with 0.
Inserting 10
Inserting 0
Removing 0
Removing 10
Result: 10
Inserting 10
sudo ./calc_client localhost 102 + +
(nothing)
Inserting 102
Removing 102
Underflow
Program Terminated