cURL / Mailing Lists / curl-library / Single Mail


Re: non-blocking?

From: Daniel Stenberg <>
Date: Tue, 17 Feb 2009 15:54:12 +0100 (CET)

On Tue, 17 Feb 2009, Christina DRS wrote:

> I would like to make this code non-blocking..can anyone help me modify it?

I would urge you to start off by reading this:

And when you think you've understood the basics, check out the multi-single.c
example which uses the multi interface to do a single request in a
non-blocking manner:

> I also have a callback method using CURLOPT_WRITEDATA. Is that blocking too?

Only if you write your callback in a funny way. I would guess that it would
return rather swiftly in all cases.

> string data = "test message";
> struct curl_httppost *post = NULL;
> struct curl_httppost *last = NULL;
> char* encoded = curl_easy_escape(_easyHandle, data.c_str(), data.length());
> string postit = "TestMessage=";
> postit +=encoded;
> curl_easy_setopt(_easyHandle, CURLOPT_POSTFIELDS, postit.c_str());
> curl_easy_setopt(_easyHandle, CURLOPT_POSTFIELDSIZE, postit.length());
> curl_easy_setopt(_easyHandle, CURLOPT_POST, 1L);
> curl_easy_perform(_easyHandle);
> curl_free(encoded);
> curl_formfree(post);

Why call curl_formfree() on a NULL pointer at this point?

Received on 2009-02-17