Based on Stephen's post I went and took a look at some old bug reports and
found he is correct. They never fixed INTERNET_OPTION_CONNECT_TIMEOUT as
the timeout is imposed by winsock layer.
They do appear to have fixed the
for HTTP only.
How to set them is quit easy.
DWORD Timeout = 5000;
InternetSetOption(NULL,INTERNET_OPTION_RECEIVE_TIMEOUT , &Timeout,
I don't know of any easy way to test INTERNET_OPTION_SEND_TIMEOUT as it
appers to deal with connection speed and\or throttling on the server side.
Docs state the following: Sets or retrieves an unsigned long integer value
that contains the time-out value to send a request. Units are in
milliseconds. If the send takes longer than this time-out value, the send
To test INTERNET_OPTION_RECEIVE_TIMEOUT is quite easy. Just create a simple
ISAPI or CGI app and call Sleep() API to make the app wait a set amout of
time before it sends back the response.
If you want to control the timeout in code you can always create a worker
thread to handle this.
224318 How To Control Connection Timeout Value by Creating Second Thread
You can also use asynchronous WinInet and cancel the call at any time.
However MFC WinInet classes are not designed to be used with async WinInet.
For async you can close the handle and then trap for
INTERNET_STATUS_HANDLE_CLOSING in the callback function.
WinHttp log may not be helpful in this case but it can help if you want to
see what is happening in WinInet.DLL
The article does cover how to use it on OS with protected by Windows file
From the KB:
For Microsoft Windows Millennium Edition or later Windows versions, follow
these steps: a. Start Windows Explorer, and then find the location where
Internet Explorer is installed on your computer. Typically this is either
the C:\Program Files\Internet Explorer folder or the C:\Program
Files\Plus!\Microsoft Internet folder.
b. If all file name extensions are visible, go to step 4. Otherwise, click
Folder Options on the Tools menu.
c. Click the View tab.
d. Click Show all files.
e. Click to clear the Hide extensions of known file types check box.
f. Close the Folder Options dialog box.
g. Click File, point to New, and then click Text Document. Name the file
"Iexplore.exe.local." If the icon for this new file remains as a Notepad
document, repeat step 3e.
h. Save a copy of the debug version of the Wininet.dll file in the
Internet Explorer folder.
If you are using a custom WinInet program, you can replace the name
"Iexplore" in "Iexplore.exe.local" with your program file name. After you
do this, run your program at a command prompt.
Windows 2000 and later Windows versions support the usage of the
Iexplore.exe.local file. This forces Internet Explorer to use just the DLLs
in the Internet Explorer folder.
Note: For custom WinInet Apps you just use the folder your app is in and
use your filename and not iexplore
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
| From: "Joe" <***@home.com>
| Newsgroups: microsoft.public.inetsdk.programming.wininet
| References: <email@example.com>
| Subject: Re: does INTERNET_OPTION_CONNECT_TIMEOUT work or not?
| Date: Mon, 3 Jan 2005 11:12:52 -0000
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
| X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
| Lines: 73
| Message-ID: <firstname.lastname@example.org>
| NNTP-Posting-Host: 81-86-223-49.dsl.pipex.com
| X-Trace: 1104750773 news-text.dial.pipex.com 16588 220.127.116.11:4267
| X-Complaints-To: ***@uk.uu.net
| Xref: cpmsftngxa10.phx.gbl
| X-Tomcat-NG: microsoft.public.inetsdk.programming.wininet
| "Stephen Sulzer" <sasulzer at seanet.com> wrote in message
| > Brian,
| > Are you sure that the Connect timeout works fully in WinInet? I am very
| > doubtful. In particular, I am pretty sure that the Connect timeout does
| > work for synchronous HTTP requests, including in IE6 SP1. Was it fixed
| > XP SP2 perhaps? The bug with the Connect timeout is not in
| > InternetSetOption, but in the core WinInet HTTP stack.
| > Also, I doubt a WinInet debug log will help with this problem.
| > Joe: in your testing, do not use a value of zero for the Connect timeout
| > (just in case it gets reinterpreted as a "special" value, namely
| > Try a small non-zero value instead, like 5 (for 5 milliseconds).
| > Stephen
| Hi Stephen,
| Well , I've tried basically everything.
| I've removed the MFC. I've tried an InternetSetOption with 0, 10,100 etc
| I've placed in on each and every HINTERNET handle etc etc ect.
| Nothing works. It *always* times out after 20 seconds. I have been able to
| get the other 2 timeouts working intermittently.
| INTERNET_OPTION_RECEIVE_TIMEOUT & INTERNET_OPTION_SEND_TIMEOUT.
| But how can I set up a scenario where I can connect but the request fails
| I can test them fully?
| Interestingly, If I InternetQueryOption without making any adjustments it
| returns 300000 (30 secs) yet the timeout is always after 20!!!!
| So something else is at play.
| Also, I have read that the cancelling thread MS fix,
| http://support.microsoft.com/kb/224318/EN-US/ will cancell all threads
| currently accessing the Internet - so this is not an option, and its dirty
| Does timeout processing work OK with asynchronous requests?
| Looks like it may be the only option.
| I've spend *ages* on this - and I have read posts indicating there has
| this same bug going back 5 or more years (hence the thread title).
| If the bug is *still* there..........
| I'm pretty pissed off to put it mildly!!!!!!!!