Answer the question
In order to leave comments, you need to log in
How safe is it to use CURL in multiple threads?
I have:
string CScanThread::HTTPReqest( string url )
{
CURL *curl;
CURLcode result;
curl = curl_easy_init( );
if ( curl )
{
curl_easy_setopt( curl, CURLOPT_ERRORBUFFER, m_CURLErrorBuffer );
curl_easy_setopt( curl, CURLOPT_URL, url );
curl_easy_setopt( curl, CURLOPT_HEADER, 0 );
curl_easy_setopt( curl, CURLOPT_CAINFO, "cacert.pem" );
curl_easy_setopt( curl, CURLOPT_WRITEFUNCTION, writer );
curl_easy_setopt( curl, CURLOPT_WRITEDATA, &m_ResponseBuffer );
result = curl_easy_perform( curl );
curl_easy_cleanup( curl );
if ( result == CURLE_OK )
return m_ResponseBuffer;
}
return string ();
}
result = curl_easy_perform( curl );
curl_easy_cleanup( curl );
Answer the question
In order to leave comments, you need to log in
Just takes off? Error code (by which you can get a message), any messages and debugging will help you.
Here is some example of multithreading: https://curl.haxx.se/libcurl/c/multithread.html . Perhaps you forgot to add something like: curl_global_init(CURL_GLOBAL_ALL); So there are no restrictions on multithreading.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question