curl_easy_perform()抛出错误

时间:2014-11-19 12:04:56

标签: ssl curl https openssl libcurl

虽然我正在调用curl_easy_perform(),但它已经崩溃了,而且我得到了 " SSL读取:错误:00000000:lib(0):func(0):reason(0),errno 110"。 需要帮助来解决这个问题。

注意:在curl_easy_perform发送http1.1命令之后,在收到http 200 OK之前,如果互联网断开连接,则会出现此错误。

if (curl) {
   curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
   curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
   curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);

   curl_easy_setopt(curl, CURLOPT_TIMEOUT, 30);
   curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, read_data);
   //url_easy_setopt(curl, CURLOPT_WRITEDATA, client);
   curl_easy_setopt(curl, CURLOPT_URL, "https://***.com:1027/page");  
   curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
   curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 0);
   printf("sending perform request\n");
   try{
   res = curl_easy_perform(curl); // Perform the request, res will get the return code 
   printf("%s",curl_easy_strerror(res));
   }catch(int e){
       printf("catch the error\n");
       fflush(stdout);
   }
   printf("perform done");

   if (res != CURLE_OK) { /* Check for errors */
       fprintf(stderr, "curl_easy_perform() failed: %s\n",
               curl_easy_strerror(res));
       printf(" Uploading failed \n");
       fflush(stdout);
       result = 0;
   }

0 个答案:

没有答案