Question
Refer to Figure 3 Using Fork. 17 for ( ; ; ) { 18 19 connfd = Accept(listenfd, (SA *) NULL, NULL); 20 21 if(childpid
Refer to Figure 3 Using Fork.
17 | for ( ; ; ) { |
18 | |
19 | connfd = Accept(listenfd, (SA *) NULL, NULL); |
20 | |
21 | if(childpid =Fork()) ==0) |
22 | { |
23 | Close(listenfd); |
24 | |
25 | DATA EXCHANGE WITH CLIENT APPLICATION |
26 | |
27 | Close(connfd); |
28 | |
29 | exit(0); |
30 | |
31 | } |
32 | |
33 | Close(connfd); |
34 | |
35 | } |
Figure 3 Using Fork.
a)Describe the purpose and basic operation of the Fork function. In your answer explain the relationship between the Child process and Parent process and identify which lines of code refer to each process. b)The listening socket is closed on line 23. Explain why it is closed here and explain whether this affects future connection requests. c)Given that the connected socket is most likely closed within the Parent process before the Child process has exchanged any data with the Client application, explain how this is possible.
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