login about faq
static void Main(string[] args)
        {
            var http = new Http();
            var success = http.UnlockComponent("Anything for 30-day trial");
            if (success != true)
            {
                Console.WriteLine(http.LastErrorText);
            }
            http.ConnectTimeout = 2;
            http.ReadTimeout = 2;
            success = http.Download("http://www.python.org/ftp/python/2.5/python-2.5.msi", "python-2.5.msi");
            if (success != true)
                Console.WriteLine(http.LastErrorText);
            else
                Console.WriteLine("Done");
        }

After 2 seconds, program still running. Can you fix it?

asked Sep 11 '12 at 09:50

chilkat's gravatar image

chilkat ♦♦
11.8k316358420


Use the AbortCheck event. See this: http://www.cknotes.com/?p=149

link

answered Sep 11 '12 at 15:31

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

ReadTimeout is the amount of time in seconds to wait before timing out when reading from an HTTP server. The ReadTimeout is the amount of time that needs to elapse while no additional data is forthcoming. During a long download, if the data stream halts for more than this amount, it will timeout. Otherwise, there is no limit on the length of time for the entire download.

link

answered Sep 11 '12 at 09:52

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

But ConnectTimeout didn't work. How to stop it after 2 seconds?

link

answered Sep 11 '12 at 09:59

thuongtin's gravatar image

thuongtin
1112

Please provide the contents of the LastErrorText.

link

answered Sep 11 '12 at 10:40

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

ChilkatLog:
  Download:
    DllDate: Aug  5 2012
    UnlockPrefix: Anything for 30-day trial
    Username: THUONGTIN:Tin
    Architecture: Little Endian; 32-bit
    Language: .NET 4.0
    VerboseLogging: 0
    hcCurDate: Tue, 11 Sep 2012 21:42:34 +0700
    hcExpire: 7/2012
    backgroundThread: 0
    url: http://www.python.org/ftp/python/2.5/python-2.5.msi
    toLocalPath: python-2.5.msi
    localFileAlreadyExists: 1
    QuickGetToOutput_Download:
      qGet_1:
        simpleHttpRequest_3:
          httpMethod: GET
          requestUrl: http://www.python.org/ftp/python/2.5/python-2.5.msi
          Connecting to web server...
          httpServer: www.python.org
          port: 80
          ConnectTimeoutMs_1: 2000
          calling ConnectSocket2
          IPV6 enabled connect with NO heartbeat.
          connectingTo: www.python.org
          dnsCacheLookup: www.python.org
          Resolving domain name (IPV4)
          GetHostByNameHB_ipv4: Elapsed time: 15 millisec
          myIP_1: 192.168.1.65
          myPort_1: 6714
          connect successful (1)
          connectElapsedMs: 359
          -- BuildGetRequest --
          Not auto-adding cookies.
          sendElapsedMs: 0
          StatusCode: 200
          StatusText: OK
          Reading response body...
          readResponseElapsedMs: 28563
        --simpleHttpRequest_3
      --qGet_1
    --QuickGetToOutput_Download
    DownloadNumBytes: 10695680
    bFileDeleted: 0
    totalElapsedMs: 28922
    ContentLength: 10695680
    Success.
  --Download
--ChilkatLog
link

answered Sep 11 '12 at 10:45

thuongtin's gravatar image

thuongtin
1112

ConnectTimeoutMs_1: 2000 totalElapsedMs: 28922

link

answered Sep 11 '12 at 10:46

thuongtin's gravatar image

thuongtin
1112

Correct. Did you understand this?

ReadTimeout is the amount of time in seconds to wait before timing out when reading from an HTTP server. The ReadTimeout is the amount of time that needs to elapse while no additional data is forthcoming. During a long download, if the data stream halts for more than this amount, it will timeout. Otherwise, there is no limit on the length of time for the entire download.

The ReadTimeout dosn't put a limit on the total download time -- it limits the amount of time when your download gets "stuck", i.e. stops mid-way and for some reason no more data is arriving.

link

answered Sep 11 '12 at 11:16

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

I want to stop download after 2 seconds. How can do it?

link

answered Sep 11 '12 at 11:26

thuongtin's gravatar image

thuongtin
1112

static void Main(string[] args)
    {
        bool abort = false;
        var http = new Http();
        var success = http.UnlockComponent("Anything for 30-day trial");
        if (success != true)
        {
            Console.WriteLine(http.LastErrorText);
        }

        http.EnableEvents = true;
        http.HeartbeatMs = 200;
        http.OnAbortCheck += (sender, e) =>
        {
            if (abort)
                e.Abort = true;
        };

        new Thread(() =>
        {
            Thread.Sleep(2000);
            abort = true;
        }).Start();

        success = http.Download("http://www.python.org/ftp/python/2.5/python-2.5.msi", "python-2.5.msi");
        if (success != true)
            Console.WriteLine(http.LastErrorText);
        else
        {
            Console.WriteLine("Done");
        }
    }
link

answered Sep 11 '12 at 22:23

thuongtin's gravatar image

thuongtin
1112

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×186
×23
×1

Asked: Sep 11 '12 at 09:50

Seen: 2,201 times

Last updated: Sep 11 '12 at 22:23

powered by OSQA