Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions