Solved

How to set timeout values for

Posted on 1997-09-03
7
1,631 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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…
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

708 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

13 Experts available now in Live!

Get 1:1 Help Now