Answered step by step
Verified Expert Solution
Question
1 Approved Answer
OPERATING SYSTEM. LINUX ENVIRONMENT: C Programming Can you please provide both SERVER and CLIENT code with the output screenshots. Thank you. I will thumbs up
OPERATING SYSTEM.
LINUX ENVIRONMENT: C Programming
Can you please provide both SERVER and CLIENT code with the output screenshots. Thank you. I will thumbs up ASAP and leave the best comment!
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 a well-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 . 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. o The server should be able to identify when a client has quit (the read operation will return O bytes instead of blocking) and in that case close the client's specific pipe and go to receive another request from a new client. 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 o ao 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 fifo open 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 1- Send request to server, in this case it will ask the user for data o Operation (one of) " Operand 1 perand 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. 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 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 intoa 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. 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 oftenStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started