Set a timeout for UrlDownloadToFile() ? [modified]
-
Hey, well if the webserver hangs or something urldownloadtofile will keep trying to connect and somewhat hang there forever. So iam in a need of a way to set a timeout for it, so itll stop executing after a set amount of time. Maybe you guys have any idea how i could realise that? And yes i do know winsock/wininet etc would be better but iam trying to learn my way up with easier functions for now :). Thanks
modified on Thursday, July 15, 2010 5:57 AM
-
Hey, well if the webserver hangs or something urldownloadtofile will keep trying to connect and somewhat hang there forever. So iam in a need of a way to set a timeout for it, so itll stop executing after a set amount of time. Maybe you guys have any idea how i could realise that? And yes i do know winsock/wininet etc would be better but iam trying to learn my way up with easier functions for now :). Thanks
modified on Thursday, July 15, 2010 5:57 AM
-
Have you tried using the callback (last parameter) and return E_ABORT? That should probably be sufficient for you.
-
Well the program is stuck because the function URLDownloadToFile() wont stop executing if the destinationserver hangs so i cant do anything.
Once more: Have you tried what I suggested? Here's a crazy thought: what if the callback is called back from the function repeatedly to allow you to monitor progress? And what if returning E_ABORT from that function will terminate the download attempt? I know it's crazy, but you're allowed to be a little crazy on Thursdays.
-
Hey, well if the webserver hangs or something urldownloadtofile will keep trying to connect and somewhat hang there forever. So iam in a need of a way to set a timeout for it, so itll stop executing after a set amount of time. Maybe you guys have any idea how i could realise that? And yes i do know winsock/wininet etc would be better but iam trying to learn my way up with easier functions for now :). Thanks
modified on Thursday, July 15, 2010 5:57 AM
If this API doesn't provide a timeout how about using an alternative? Use a HTTP client library (Alhem, Boost, IP*Works, Poco, Sharkengine) or one of the Windows HTTP APIs, e.g. WinHTTP (MSDN), Asynchronous WinHTTP Library (CodeProject). See if it helps :) /M