Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1841
  • Last Modified:

How to set timeout values for

I'm trying to set the timeout values for a InternetSession, but so far with no luck. I'm using the following code, which set the timeout value to 2 seconds, using SetOption, and then double check using QueryOption:


CInternetSession *PInetSession;
CStdioFile *pFile;
DWORD dwTO;
 
pInetSession = new CInternetSession( );
pInetSession->QueryOption(INTERNET_OPTION_CONNECT_TIMEOUT, dwTO);
// dwTO's value is now 60000, i.e. 60 seconds.
// (Default value?)
 
pInetSession->SetOption(INTERNET_OPTION_CONNECT_TIMEOUT, 2000);
 
pInetSession->QueryOption(INTERNET_OPTION_CONNECT_TIMEOUT, dwTO);
// dwTO's value is now 2000, i.e. 2 seconds.
 
pFile = pInetSession->OpenUrl( "http://www.blaha.com" )  

But, the connection opened by OpenUrl still use a timeout of  60 seconds! (Which is far too much to serve my purpose...)

I've tried to close the session handle after two seconds (from another thread), but OpenUrl still wait until timeout before returning with a "Operation Cancelled" error message. So, I guess, the timeout value still applies, even though I close the handle...
 
Anyone got a clue why CInternetSession won't take the timeout values I set? Any help would be appreciated!
 
If you help me, I'll send you a postcard from Sweden! :-)
 
Thanks in advance,
Johan Dewe
0
dewe
Asked:
dewe
1 Solution
 
deweAuthor Commented:
Edited text of question
0
 
deweAuthor Commented:
Edited text of question
0
 
deweAuthor Commented:
Edited text of question
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
deweAuthor Commented:
Edited text of question
0
 
davmarcCommented:
What does QueryOption(INTERNET_OPTION_CONNECT_TIMEOUT) returns after calling pInetSession->OpenUrl("http://www.blaha.com")?

Davide Marcato.
0
 
mikeblasCommented:
You need to also set INTERNET_OPTION_CONNECT_TIMEOUT, INTERNET_OPTION_CONNECT_RETRIES, and INTERNET_OPTION_CONNECT_TIMEOUT.  Depending on what protocol you're using, INTERNET_OPTION_CONTROL_RECEIVE_TIMEOUT and INTERNET_OPTION_CONTROL_SEND_TIMEOUT INTERNET_OPTION_DATA_SEND_TIMEOUT and INTERNET_OPTION_DATA_RECEIVE_TIMEOUT might be important.

The documentation carefully explains what these options all mean when taken together.  The time between your call and when it returns failure is related to _all_ of these option settings, not just to the CONNECT_TIMEOUT.

.B ekiM

0
 
muneCommented:
Check out...
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now