Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using C socket programming language Write a concurrent TCP server program according to the following requirements: 1. the server should keep track of how many
Using C socket programming language
Write a concurrent TCP server program according to the following requirements:
1. the server should keep track of how many clients connected to the server
2. after a client request to connect with the server, the server should fork a child process to handle that request
3. the child process should call the function int receiveAndSum(int skfd)
4. The function receiveAndSum
a. should read exactly 5 integers from the client where the client will send the numbers individually (assume Writen function discussed in the class is already implemented and is available for you to use.)
b. Once all the numbers are received, the function will compute and send the sum of the 5 numbers back to the client
c. the function should also return the summation result
5. the child process should store the returned result in the array magicallySharedArray, which you can assume is shared between the parent process and all its child processes.
6. After 4 clients are done providing their numbers, the server should find maximum summation (out of those already stored in the magicallySharedArray) and print it.
7. All socket descriptors should be closed properly
8. The server should listen on port 5555
9. The server would accept connections on any of its interfaces
10. The server must wait for 4 clients (connecting to server via forked child processes) to send the required data.
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