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!
本文讨论了在进行HTTP客户端性能测试时遇到的多线程、Socket关闭与数据传输间断的问题。通过使用Wireshark进行分析,揭示了在关闭写端Socket后,服务器可能停止进一步内容发送的现象。分析了HTTP/1.1中Connection:KeepAlive和Connection:Close两种状态下的行为,并最终借助Wireshark找到了问题原因。
1353

被折叠的 条评论
为什么被折叠?



