Solved

How to set timeout values for

Posted on 1997-09-03
7
1,655 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
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now