Discussion:
WinInet connection resets
(too old to reply)
s***@gmail.com
2005-04-14 16:44:11 UTC
Permalink
I'm working on a little WinInet HTTP client, and it looks like the
client sends a RST every time the program ends, even though I'm closing
all of my HINTERNETs in the right order.

I downloaded the httpauth sample from msdn and it does the same thing.

Is this the expected way for WinInet to terminate connections? The
only workaround I've gotten working is grabbing the socket during a
callback and then calling CloseHandle() on it after I close my wininet
handles. Surely there must be a better way.

Thanks.

-Steve
Stephen Sulzer
2005-04-19 01:54:13 UTC
Permalink
WinInet can persist TCP connections beyond the end of an HTTP request.
WinInet implements a process-wide "keep-alive" socket pool, which allows it
to reuse an existing socket connection for a subsequent request to the same
server:port destination, avoiding the overhead of setting up a new TCP
connection. So closing your WinInet HINTERNET handles does not imply that
the associated socket connection is closed. And you should not access the
socket handle directly. When WinInet is shut down, these socket connections
are forcibly terminated (thus the RSTs).

If you do not want WinInet to keep the socket connection alive after an HTTP
request, then set a "Connection: Close" header to your HTTP request.

- Stephen
Post by s***@gmail.com
I'm working on a little WinInet HTTP client, and it looks like the
client sends a RST every time the program ends, even though I'm closing
all of my HINTERNETs in the right order.
I downloaded the httpauth sample from msdn and it does the same thing.
Is this the expected way for WinInet to terminate connections? The
only workaround I've gotten working is grabbing the socket during a
callback and then calling CloseHandle() on it after I close my wininet
handles. Surely there must be a better way.
Thanks.
-Steve
Continue reading on narkive:
Loading...