Question: Refer to Figure 1 - A recv( ) Primitive: a)Explain the purpose of the recv() primitive identifying the source buffer from which the incoming data
Refer to Figure 1 - A recv( ) Primitive:
a)Explain the purpose of the recv() primitive identifying the source buffer from which the incoming data stream originates.
b)Assuming the test condition within the whlle loop is true i.e. numBytes > 0, explain what this means in terms of the status of the socket identified by the descriptor clntSock.
c) Assume a properly formatted HTTP GET request is sent to a HTTP server containing this code. Explain the problem associated with this implementation of the recv() primitive and how this problem might be addressed.
| IGNORE ALL PRIOR LINES. | |
| 21 | while ((numBytes = recv(clntSock, recvbuffer, BUFSIZE 1, 0)) > 0) |
| 22 | { |
| 23 | recvbuffer[numBytes] = '\0' ; |
| 24 | fputs(recvbuffer, stdout); |
| 25 | } |
| 26 | if (numBytes < 0) |
| 27 | DieWithSystemMessage("recv() failed"); |
| IGNORE ALL SUBSEQUENT LINES |
Figure 1 : A rec ( ) Primitive
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
