Building an HTTP client for some performance testing purposes. Multiple sockets, I/O multiplexing, two threads. One sender pushing pipelined requests and one receiver dragging all server responses.
In order to simplify program logic I tried to shutdown the writer end after all requests has been sent
shutdown (s, SHUT_WR);
at the same time responses are being read from the other thread. I thought that since I used SHUT_WR, the receiver should be able to get data as nothing happened.
It didn't work. Data stops at half way.
I tried with HTTP/1.1 Connection: KeepAlive, Connection: Close. Neither worked out the trick. Down stream stops at ~60k every time.
After some sharp pointers from my old friend Bluntblade, Wireshark came into rescue.
When the shutdown call is triggered, client sends an FIN packet to server. Upon receiving this packet, server may stop serving further content.
D'm it!