Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Set a timeout for UrlDownloadToFile() ? [modified]

Set a timeout for UrlDownloadToFile() ? [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ALLERSLIT
    wrote on last edited by
    #1

    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

    N M 2 Replies Last reply
    0
    • A ALLERSLIT

      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

      N Offline
      N Offline
      Niklas L
      wrote on last edited by
      #2

      Have you tried using the callback (last parameter) and return E_ABORT? That should probably be sufficient for you.

      home

      A 1 Reply Last reply
      0
      • N Niklas L

        Have you tried using the callback (last parameter) and return E_ABORT? That should probably be sufficient for you.

        home

        A Offline
        A Offline
        ALLERSLIT
        wrote on last edited by
        #3

        Well the program is stuck because the function URLDownloadToFile() wont stop executing if the destinationserver hangs so i cant do anything.

        N 1 Reply Last reply
        0
        • A ALLERSLIT

          Well the program is stuck because the function URLDownloadToFile() wont stop executing if the destinationserver hangs so i cant do anything.

          N Offline
          N Offline
          Niklas L
          wrote on last edited by
          #4

          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.

          home

          1 Reply Last reply
          0
          • A ALLERSLIT

            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

            M Offline
            M Offline
            Moak
            wrote on last edited by
            #5

            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

            Chat in Europe :java: Now with 24% more Twitter

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups