Write a program to provide a simple calculator service

Assignment Help C/C++ Programming
Reference no: EM132238543

This assignment is meant to:

1. Get you started compiling and debugging programs in a UNIX/Linux machine
2. Introduce students to writing basic client/server programs in C usingthe UNIX/Linux platform
3. Provide an opportunity to write code that will become the base for projects similar to that of a simulated operating system component

Objective: Create programs that are run independently and can perform simple IPC using FIFOs/named pipes to pass information back and forth in a client/server fashion.

This assignment requires the analysis, implementation, testing and documentation of two C program that use C on the Linux server sapphire or your own Linux box or virtual machine. A server program and a client program that will be run concurrently.

Server program:
The server program will provide a simple "calculator" service to clients that connect with it and send requests.

Server program will be an iterative server (can process ONLY one client at a time) and it needs to:

• Create awell-known FIFOs where it will read its inputs from the client and open it in READ mode (will block of course until a client opens the fifo in write mode).

• READ a requests from a new clients asking to "connect" to the server, this requests should include the client number and the name of that client-specific FIFO (used by the client to receive replies from the server). Server should open that FIFO in WRITE mode, save the file descriptor for use when replies need to be sent to the client.

• Then go into a loop to read operation requests from the client which will be of two requests:
o Request from the client asking for an operation to be performed. This request should include the client number and some data (your choice: string, number, etc.) The data should include three parts a) an operator (+,-,* or /) b) operand 1 and c) operand 2. After performing the indicated operation, the server should use the client specific fifo to send a reply with the result.

The server should be able to identify when a client has quit (the read operation will return 0 bytes instead of blocking) and in that case close the client's specific pipe and go to receive another request from a new client.

o There should be a "special operation-STOP" that can be sent by a client to indicate to the server that it should close all fifos and terminate (this is not normally part of a standard server code which should run indefinitely, but will give you a way to gracefully shutdown the server

Note: Server program must print appropriate messages to the screen to show the client it's interacting with, the request received and the reply being sent.

Client Program:
The client program will "connect" to the server through the well-known FIFO and send requests through it to the server, more specifically, the client program should:
• Acquire from the user (through the command line or reading from the keyboard) what the client number this instance of the program will be (i.e., client 1, client 2, etc.)
• Open the well-known server's fifo in write mode to communicate with the server (which will unblock the server from its fifoopen call)
• Create the client-specific FIFO using an appropriate name (e.g., ClientNfifo, where N is the client number) and send the initial "connect request" to the server including Client number and name of the client-specific FIFO.
• Open the client-specific FIFO in READ mode to be able to read replies from the server. This will block the client until the server opens the fifo in write mode.
• After this,the client should go into a loop where the client will ask the user what to do next? providing three choices:
o 1 - Send request to server, in this case it will ask the user for data:
• Operation (one of)
+
-
*
/
• Operand 1
• Operand 2

read the three pieces of data from the keyboard and appropriately format an operation request and send to the server, then read the reply from the server in the client-specific FIFO and write it to the screen.

o 2 - QUIT - indicates THIS client does not want to issue more requests to the server, it should close its pipes and exit. A new client can now connect to the server.

o 3 - STOP - indicates THIS client does not want to issue more requests to the server, and it should also send a STOP request to the server (so that it can gracefully terminate) before closing its pipes and exiting. No more clients can connect to the server after this.

The first step in writing a client/server application is define the communications protocol between both applications. In other words, how are you going to encode the requests and reply into a message, you can encode data in string forms, you can use integers data, separating each piece with a "," "-" a space, a new line character, or any other kind of separator.

Reference no: EM132238543

Questions Cloud

Provide statistical write-up including Tukey test results : State the hypotheses for this test. State the decision rule and explain why. Provide a statistical write-up, including the Tukey's test results
Algorithm to decide if an input edge : You are given a weighted graph G = (V,E) with positive weights, c(i) for all i in E. Give a linear time (O(|E| + |V|)) algorithm to decide if an input edge
Think about weddings-funerals and graduations : Think about weddings, funerals, and graduations, as well as performances you have seen.
Password functionality in a secured manner : 1. How would you suggest using forgotten Password functionality in a secured manner? Illustrate with 2 real world safe practices.
Write a program to provide a simple calculator service : CSCI 4534 - Operating Systems - Stanford University - write code that will become the base for projects similar to that of a simulated operating system
Identify the major stakeholders in your organization : Identify the relationship among any reward systems and organizational goals and what positive or negative effect there is on employee productivity.
Create an ad for particular product or service : Assume that you are a marketing team member who were assigned to create an ad for particular product or service.
Did you find an interesting project : Did you find an interesting project? Did it come across that you yourself seemed interested in the project?
Adverse effects of a bad password : 1. List out 5 adverse effects of a Bad password used in an online web application?

Reviews

len2238543

2/20/2019 9:40:00 PM

Date Due: Monday, 18th, 11:59pm to Blackboard Create a zip file with both your programs source file(s) and upload to blackboard please. Make incremental progress as you develop your code and back up your files often!!

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd