cURL / Mailing Lists / curl-library / Single Mail

curl-library

File type to download

From: jvp <jvp_at_compu-weigh.com.au>
Date: Sun, 21 Jun 2009 15:40:49 +1000

Hi all

Beginner with cURL, so please be gentle. :)
Developing using FreeBasic on XP, for MS-DOS on a separate machine.
Using cvs version of 20th June.
My main need is to let my customers automatically update versions of
executable files
from my website. A test program that I have written to transfer a web
page from
my site works perfectly, and downloads a html document of 5kb in a few
seconds.
Loading the page on the xp machine shows no errors in the transfer.

However, when I try to download an executable file of 677kb, it downloads
about 300 bytes, and no further action. The second time I tried , it
downloaded 43kb.
The verbose option shows the correct file size to the screen
but after that no further info gets printed.My timer aborts after 300 sec's
Although the code is for FreeBasic, it is easily readable. I know that I
am not doing success checking
after each call, but this is only a test, and there are no errors when I do.
Note website name changed.
My question is, have I forgotton to set certain options that are needed,
or am I going about this
all wrong for that type of transfer.
Any constructive suggestions appreciated.

    http_handle = curl_easy_init() 'Initialize and get Handle
    FP = FreeFile
    Open "MC211.exe"For Binary Access Write As #FP
    '-------------------------------
    curl_easy_setopt( http_handle, CURLOPT_VERBOSE,1)
    curl_easy_setopt( http_handle, CURLOPT_URL,
"http://www.mysite.com.au/Downloads/Mc211.exe" )
    curl_easy_setopt( http_handle, CURLOPT_WRITEFUNCTION, @write_callback )
    multi_Handle = curl_multi_init()
    curl_multi_add_handle(multi_handle, http_handle)
    Dim StartTime As Double = Timer
    Do
        If Timer - StartTime > 300 Then Exit do
        curl_multi_perform(multi_handle, @running)
        If running < 1 Then Exit Do
    Loop
    '-------------------------------
    Close #FP
    curl_multi_cleanup(multi_handle) 'reset options to default.
    curl_easy_cleanup(http_handle) 'cleanup and quit cURL
    Dim EndTime As Double = Timer
    Print Using "Time Elapsed =###.## Sec's"; EndTime - StartTime
    End

The write_callback function simply writes bytes received to the file.

Regards
Received on 2009-06-21