Done Sending Not Done
write(fd, request, request_len);
shutdown(fd, SHUT_WR); /* sends FIN */
ssize_t k;
while ((k = read(fd, buf, sizeof buf)) > 0)
consume(buf, k);
/* loop exits when k == 0 */
This is the standard shape of a client that streams a request of unknown length and then reads a response of unknown length. What does shutdown(fd, SHUT_WR) buy, and when does read return 0?
Sign in to answer questions and track your progress
Sign In