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

  Write a function called fibonacci

By definition, the first two numbers in the Fibonacci sequence are 0 and 1, and each subsequent number is the sum of the previous two;

  Design an employee class

Design an Employee class that has fields for the following pieces of information: Employee Name and Employee Number

  Differences between data warehouses and data marts

Write a two-page (500 word) paper that discusses the differences between data warehouses and data marts. Also, discuss how organizations can use data warehouses and data marts to acquire data. You must use at least two sources for your paper.

  Contrast the way in which syntax errors are treated

Contrast the way in which syntax errors are treated in compiled languages such as C++ and an interpreted language such as Java. Provide an example to support your response.

  The reverse of each word, and a palindrome checker

give us the first letter of each word, the first half of each word, the reverse of each word, and a palindrome checker to see if the word is a palindrome.

  Algorithm to be converted to c language

algorithm to be converted to c language

  Write a c function called bspline

Write a C function called Bspline that takes as input a single double precision argument called x. The function returns a double precision value y determined as given

  Give a divide and conquer algorithm for the problem

Give a divide and conquer algorithm for the same problem that takes time theta(log(n)).

  Write function to find whether number is perfect number

Write down the function perfect which determines whether number is perfect number or not. This function must receive number and return true if number is perfect.

  Write a program to ask the user for the length of the room

Write a program to ask the user for the length of the room (in inches) to be carpeted, the width of the room (in inches) to be carpeted.

  The goal of this project is to create

The goal of this project is to create a simple command line program that reads in a single word from the command line (use the "int argc, char * argv[]" approach discussed in class and in previous projects) and stores the unique letters of that wo..

  Calculate square or cube of positive integer input by a user

Assignment: Hands-On Lab. This program will provide options for a user to calculate the square or cube of a positive Integer input by a user.

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