Question
Write a server program and a client program in C that will be run concurrently. Server program: The server program provides a simple search for
Write a server program and a client program in C that will be run concurrently.
Server program:
The server program provides a simple search for a specific value in an array sent to it from a client. If the value appears in the array, the server indicates the index of the first occurrence of that value in the array. The server sends the client search value and its array position. If the value does not occur in the array, only the search value and an appropriate return code is returned to the client.
The server program needs to:
- Determine an integer value to be searched for
- Create a well-known FIFO, named FIFO_to_Server through which the server reads inputs from the client
- Open FIFO_to_Server in READ mode
- Read a request from a client that includes a struct containing a size integer and array values of that size, all integers.
- Find the index (start counting with zero) of the search value, if one exists
- Create a FIFO named FIFO_to_Client through which the server responds to the client
- Open FIFO_to_Client in WRITE mode
- Write the search value and the index position back to the client through FIFO_to_Client
- Close FIFO_to_Client
- Unlink FIFO_to_Client
- Close FIFO_to_Server
- Unlink FIFO_to_Server
Client Program:
The client program will request an array size and array elements to fill the array. The client program should:
- Open FIFO_to_Server in WRITE mode
- Prompt the user for an array size
- Prompt the user for elements to fill that array
- Write the struct that includes the array size and the array to FIFO_to_Server
- Close FIFO_to_Server *
- Open the FIFO_to_Client in READ mode
- Read the response from the server from FIFO_to_Client
- Print a message such as The value 87 occurs in array position 4
- Close FIFO_to Client
Step 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