cURL / Mailing Lists / curl-library / Single Mail

curl-library

Segmentation Fault

From: Mauricio Ramirez <mauricio.ramirez_at_lacity.org>
Date: Wed, 12 Dec 2012 14:04:26 -0800

I'm trying to perform a post from c++. I'm getting a segmentation fault
when calling the curl_easy_perform. I'm new to curl, but this is my code
so far.

CURL *curl;
CURLcode res;
curl = curl_easy_init();
if ( curl )
{
curl_easy_setopt( curl, CURLOPT_PROXY, "IP_OF_PROXY_AND_PORT" );
curl_easy_setopt( curl, CURLOPT_URL, "http://posttestserver.com/post.php" );
curl_easy_setopt( curl, CURLOPT_POSTFIELDS, data.c_str() );
 // if we don't provide POSTFIELDSIZE, libcurl will strlen() by itself
curl_easy_setopt( curl, CURLOPT_POSTFIELDSIZE, data.c_str());
res = curl_easy_perform( curl );

// always cleanup
curl_easy_cleanup( curl );
}

-- 
Mauricio Ramirez
Programmer Analyst
Public Safety Fire Dispatch Division
(213) 484 - 6773
There are two ways to write error-free programs; only the third one works.

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