First, what's the preferred way to use WinInet – the APIs (such as
InternetOpen, HttpOpenRequest, HttpSendRequest, InternetSetOption) or
the classes (CInternetSession::GetHttpConnection(),
CHttpConnection::OpenRequest, ChttpFile::SendRequest() )?
Currently, I am using the classes and am trying to set the connect,
send, and receive timeouts but can't get it to work. I've seen the
bug in the MS knowledge base and have upgraded to IE6, but they still
don't work. I've set all 3 timeouts (INTERNET_OPTION_CONNECT_TIMEOUT,
INTERNET_OPTION_SEND_TIMEOUT, and INTERNET_OPTION_RECEIVE_TIMEOUT ) to
be 60 seconds as follows:
session.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT,60000,0);
session.SetOption(INTERNET_OPTION_SEND_TIMEOUT,60000,0);
session.SetOption(INTERNET_OPTION_RECEIVE_TIMEOUT,60000,0);
I've also set the number of retries to 5 as follows:
session.SetOption(INTERNET_OPTION_CONNECT_RETRIES,5,0);
I assume the retries applies only to the connect, but haven't been
able to verify that.
I've tried calling SetOption method on the CinternetSession object,
ChttpConnection object and the CHttpFile object with the same results.
An interesting observation is that if the server PC is on but the
webserver is disabled (using Netscape Enterprise Server), the
CHttpFile::SendRequest() call throws a CinternetException immediately
(not after the 60 second timeout I am setting). The exception is
12029 (A connection with the server could not be established).
However, if the webserver PC is powered off, CHttpFile::SendRequest()
throws an exception after 20 seconds (regardless of the timeout length
I specify). This time, the exception is 12002 Request has timed out.
In both cases, I thought it was interesting the GetHttpConnection and
OpenRequest calls succeeded – they must not be trying to actually
establish a connection until sendRequest is called.
Anyone have any insight to this madness? Thanks in advance for any
help you can provide.
When using HTTP wininet will not try and make the connection to the server
until the HttpSendRequest.
Thanks
Brian [MS]
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
Also, just to clarify, since CInternetSession::GetHttpConnection() and
CHttpConnection::OpenRequest do not actually make the connection, does
that mean the timeout and retries settings do not apply here, only
when ChttpFile::SendRequest() is called?
Thanks again,
Joe