title: is it safe to use CURL in multi threaded program, How can I make it thread safe?
body: <p>I planned to use CURL to communicate with server. And this communication will take place as a separate thread. </p>
  
  <p>I have a curl wrapper class as given below.</p>
  
  <p>If I use the object of this wrapper class to communicate with different server in different thread or in the same thread would it be thread safe? </p>
  
  <p>The following description from <a href="https://curl.haxx.se/libcurl/c/curl_global_init.html" rel="nofollow noreferrer">curl website</a> confuse me.</p>
  
  <blockquote>
    <p>This function is not thread safe. You must not call it when any other thread in the program (i.e. a thread sharing the same memory) is running. This doesn't just mean no other thread that is using libcurl. Because curl_global_init calls functions of other libraries that are similarly thread unsafe, it could conflict with any other thread that uses these other libraries.</p>
  </blockquote>
  
  <pre><code>class curlWrapper
   { 
  private:
      CURLcode curlCode;
      CURL *curlHandle;
      struct curl_slist *header = NULL;
      MemoryStruct response;
  
  public:
      curlWrapper(){        
          curl_global_init(CURL_GLOBAL_ALL);      
  
      }        
      ~curlWrapper(){
          curl_global_cleanup();            
      }
  
      CURL* curlInit();// curl_easy_init()
      CURLcode curlClose();// curl_easy_cleanUp()
  
      void initializeConnection();
      void sendRequest(const char* request);
      char* getResponse();
      void setMemorytoWrite();
      void listen();
      void closeConnection();
      void setURL(const char* url);
      void setHttpHeader(const char * contentType, const char * charSet);
      void setTrace(bool trace);// If true trace will be displayd
      void curlExec();
  
  };` 
  </code></pre>
  
  <p>could anyone please clarify the confusion?</p>
  
  <p>Language: c++
  Operating system: 
    In development : OS X.</p>
  
  <p>In client side : This code will be installed in client machine which means they may use any OS.</p>
  
  <p>Thanks</p>