Solved

How to set timeout values for

Posted on 1997-09-03
7
1,721 Views
Last Modified: 2013-11-20
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
Comment
Question by:dewe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 

Author Comment

by:dewe
ID: 1305613
Edited text of question
0
 

Author Comment

by:dewe
ID: 1305614
Edited text of question
0
 

Author Comment

by:dewe
ID: 1305615
Edited text of question
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:dewe
ID: 1305616
Edited text of question
0
 
LVL 4

Expert Comment

by:davmarc
ID: 1305617
What does QueryOption(INTERNET_OPTION_CONNECT_TIMEOUT) returns after calling pInetSession->OpenUrl("http://www.blaha.com")?

Davide Marcato.
0
 
LVL 11

Accepted Solution

by:
mikeblas earned 200 total points
ID: 1305618
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
 

Expert Comment

by:mune
ID: 1305619
Check out...
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question