cURL / Mailing Lists / curl-library / Single Mail

curl-library

asynchronous transfer doesn't start

From: Lisa Vitolo <syn.shainer_at_gmail.com>
Date: Wed, 10 Oct 2012 20:53:07 +0200

Hello to this list,

I'm using libcurl 7.21.6-2 for handling asynchronous transfers in a project
of mine, but without success. Below I include a sample C code that
reproduces the incorrect behavior I'm experiencing. If I use the easy
interface, the transfer goes fine, but when I switch to the multi
interface, it prints the "dltotal is zero" message and then hangs there
without receving data. The URL in the sample is valid and contains a simple
tutorial, so if you trust my word about it you can use it just fine.
I tried everything but the result is still this: I'm surely doing something
wrong but from the tutorial and the example codes I cannot find out what.
Can you please help me solving this issue?

Thank you very much,
Lisa

size_t reportProgress(void* clientp, double dltotal, double dlnow, double
ultotal, double ulnow)
{
    if (dltotal != 0) {
        printf("Progress: %d\n", (int)((dlnow / dltotal) * 100));
    } else {
        printf("dltotal is zero\n");
    }

    return 0;
}

size_t writeData(void* buffer, size_t size, size_t nmemb, void* clientp)
{
    printf("writeData callback\n");
    return (size * nmemb);
}

int main(int argc, char** argv)
{
    curl_global_init(CURL_GLOBAL_ALL);
    CURL* handle = curl_easy_init();
    int progress = 0;

    curl_easy_setopt(handle, CURLOPT_URL, "
http://giudoku.sourceforge.net/media/DFA.pdf");
    curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, writeData);
    curl_easy_setopt(handle, CURLOPT_NOPROGRESS, 0);
    curl_easy_setopt(handle, CURLOPT_PROGRESSFUNCTION, reportProgress);

    CURLM* multiHandle = curl_multi_init();
    curl_multi_add_handle(multiHandle, handle);
    curl_multi_perform(multiHandle, &progress);
    while (1);
}

-- 
“I'll be more enthusiastic about encouraging thinking outside the box when
there's evidence of any thinking going on inside it.”

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-10-10