Solved

How to set timeout values for

Posted on 1997-09-03
7
1,679 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Looking for a specific application/software 2 110
windows 10 how make picture as desktop background 2 62
maxBlock challenge 30 129
Problem to open Excel file 15 133
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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 Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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.

773 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