Discussion:
InternetCloseHandle Latency unblock synchronous HttpSend child thr
(too old to reply)
dlyle
2008-04-11 15:48:01 UTC
Permalink
Sorry for the caveman speak title -- I couldn't fit all the key words
I wanted to "tag" this subject with and also have a full sentence!

Basically I am trying to implement the suggestion of the kb article:
"How To Control Connection Timeout Value by Creating Second Thread" at
the website: "http://support.microsoft.com/kb/224318/EN-US/". The only
difference with my code is that I'm trying to control the connection timeout
for HttpSendRequest. With a timeout value of 5000 ms, the
WaitForSingleObject call times out in 5 seconds as expected but when I
subsequently call InternetCloseHandle on the HttpRequest handle and the Http
connection handles on the parent thread, the child thread's blocked call to
HttpSendRequest doesn't seem to unblock for at least 10-20 seconds after
InternetCloseHandle was called on the main (parent) thread. Is there a way
around this latency?

I'm testing the send timeout using the Fiddler2 internet tool that allows
you to set breakpoints for specific url requests. Thus I set a breakpoint in
Fiddler2 for the url the code is sending an HttpSendRequest to via WinInet,
and I don't hit the button to continue from the breakpoint (i.e. forward the
request from Fiddler2). This causes the timeout in the main thread that has
launched a separate thread for HttpSendRequest and is waiting on that thread
with the given timeout value. When InternetCloseHandle is then called upon
timeout expiration the child thread isn't unblocking its call to
HttpSendRequest.

Has anyone experienced similar issues. I'd rather not have to rewrite the
code to use the asynchronous WinInet calls, but perhaps that is the best
solution. If that is, does anyone have links to good examples of programming
WinInet (ideally with good error handling) using the asynchronous calls?

Thanks! :)
dlyle
2008-04-11 18:31:03 UTC
Permalink
I just found the following apparently useful website on using WinInet
asynchronously (at least regarding making the connection and reading from the
connection):

http://www.codeproject.com/KB/IP/asyncwininet.aspx
Volodymyr M. Shcherbyna
2008-04-12 11:26:14 UTC
Permalink
At this NG the answer (because this question is asked quite often) for the
question "how to make timeouts in syncr. wininet" is "move into async. mode
of wininet".
--
V.
This posting is provided "AS IS" with no warranties, and confers no
rights.
Post by dlyle
I just found the following apparently useful website on using WinInet
asynchronously (at least regarding making the connection and reading from the
http://www.codeproject.com/KB/IP/asyncwininet.aspx
dlyle
2008-04-11 20:53:01 UTC
Permalink
The following microsoft website has the most comprehensive example I've seen
thus far on programming WinInet asynchronously. It isn't easily found from
visual studio's help on WinInet. Note: If you're interested in such
documentation, I'd highly recommend printing it or saving a copy to your
local hard drive since such older microsoft documentation web links have a
tendency to become broken links or even eventually redirected to a page that
says that this url is no longer valid but can now be found "here" where
"here" becomes the microsoft home page!

http://msdn2.microsoft.com/en-us/library/cc185684(VS.85,printer).aspx
Loading...