Try answering these questions to test your knowledge on this chapter:
- How can we tell whether the next call to recv() will block?
- How can you ensure that select() doesn't block for longer than a specified time?
- When we used our tcp_client program to connect to a web server, why did we need to send a blank line before the web server responded?
- Does send() ever block?
- How can we tell whether the socket has been disconnected by our peer?
- Is data received by recv() always the same size as data sent with send()?
- Consider the following code:
recv(socket_peer, buffer, 4096, 0);
printf(buffer);
What is wrong with it?
Also see what is wrong with this code:
recv(socket_peer, buffer, 4096, 0);
printf("%s", buffer);
The answers can be found in Appendix A, Answers to Questions.