WinInet connection resets

124 views
Skip to first unread message

steveus...@gmail.com

unread,
Apr 14, 2005, 12:44:11 PM4/14/05
to
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

unread,
Apr 18, 2005, 9:54:13 PM4/18/05
to
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


<steveus...@gmail.com> wrote in message
news:1113497051.3...@f14g2000cwb.googlegroups.com...

Reply all
Reply to author
Forward
0 new messages