I am using urldownloadtofile to download a web content as below
CBSCallbackImplPX callback;
callback.nTitmeOut=10;
if ( URLDownloadToFile( 0, "http://www.zoominfo.com/login", "a.html", 0,&callback ) != S_OK )
.
.
.
.
.
class CBSCallbackImplPX : public IBindStatusCallback
.
.
.
.
.
STDMETHODIMP CBSCallbackImplPX::OnProgress(ULONG ulProgress,
ULONG ulProgressMax,
ULONG ulStatusCode,
LPCWSTR szStatusText)
{
try{
m_endDownload=clock();
int nTimeTakenForThisDownload=0;
nTimeTakenForThisDownload=((int)( m_endDownload -m_startDownload)/CLOCKS_PER_SEC) ;
if(nTimeTakenForThisDownload>=nTitmeOut)
{
return E_ABORT;
}
return S_OK;
}catch(...)
{
int x=0;
}
}
I have used here callback function and checking for custom timeout through OnProgress()
It works fine ,If i give 20 sec time out or even 2 sec timeout it is coming after that time and it is been possible only because it frequently callsback OnProgress().
But if I try to open a page which have the probability to get time out before desired time.[like trying to open Zoominfo.com from a gateway where it is blocked]it is not calling OnProgress() for around 5 minute.
I have IE8 so as Microsoft told their default timeout in IE8 is 5 minute.
is that the reason for what I found that OnProgress() is not been called.
from urlmon.dll the call directly came to
STDMETHODIMP_(ULONG) CBSCallbackImplPX::Release()?
Is there any way so that I need not to wait for 5 minute[only 20 sec is enough for me]
in case if the url is not responding?
for further details please refer to this link:
http://support.microsoft.com/kb/833301