Discussion:
Reusing an opened connection
(too old to reply)
t***@gmail.com
2006-11-14 08:50:35 UTC
Permalink
Hello all,
I'm reusing the same HINTERNET handle returned from InternetConnect to
send many HTTP requests.

My question is:

If, at some point, I receive an error when calling
HttpOpenRequest/HttpSendRequest,
is there any point in recalling InternetConnect and then
HttpOpenRequest/HttpSendRequest?
Or is it the same as recalling HttpOpenRequest/HttpSendRequest on the
same opened handle?

Thanks!
Vladimir Scherbina
2006-11-15 09:01:17 UTC
Permalink
This post might be inappropriate. Click to display it.
t***@gmail.com
2006-11-16 07:04:41 UTC
Permalink
Hi Vladimir,

Thanks for the reply,

But it seems to me, that once I close the handle to the request, the
tcp/ip connection to the server is closed (I used proxytrace to see
this), isn't it enough to call HttpOpenRequest?

Even in the MSDN documentation they say:
"...For maximum efficiency, applications using the Gopher and HTTP
protocols should try to minimize calls to InternetConnect and avoid
calling this function for every transaction requested by the user. One
way to accomplish this is to keep a small cache of handles returned
from InternetConnect..."

Thanks
Post by Vladimir Scherbina
I think it may depends upon the configuration of server. If the server is
configured to create new connection for each request then your code may fail
in the next HttpSendRequest calls. So it's better (I think) not to rely upon
the server's configuration and make new InternetConnect per new request.
On the other hand, if you code for some specific server and can control it's
configuration you may reuse the handle - it seems much efficient solution of
course.
--
Vladimir (Windows SDK MVP)
Post by t***@gmail.com
Hello all,
I'm reusing the same HINTERNET handle returned from InternetConnect to
send many HTTP requests.
If, at some point, I receive an error when calling
HttpOpenRequest/HttpSendRequest,
is there any point in recalling InternetConnect and then
HttpOpenRequest/HttpSendRequest?
Or is it the same as recalling HttpOpenRequest/HttpSendRequest on the
same opened handle?
Thanks!
Loading...