开发者

Continue WinHTTP connection after write shutdown

I'm using WinHTTP to send data to a web server script and in some cases I need the server to kill the incoming data (as it is not required) but still return a response to the client app. I'm using stream_socket_shutdown(STREAM_SHUT_RD) from the server end to end the incoming data, then sending a response back as normal. The problem lies with WinHTTP, I get a negative response back from WinHttpWriteData() as expected and stop sending data but when I call WinHttpReceiveResponse() it returns false and GetLastError() returns ERROR_WINHTTP_CONNECTION_ERROR.

Is there a way to perhaps reset the internal error condition for WinHTTP? Or another way to rece开发者_运维技巧ive the response after the connection has been broken by the server?

Thanks, J


If you kill the connection from the server side, the receive on the client will fail. This is how WinHTTP is designed to work.

Can't your server just discard unwanted incoming data?

Why is your client still sending when the server is expecting to send it a response? Perhaps the protocol implied in your HTTP usage can be adjusted to reduce sending of unwanted data from the client in this scenario.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜