curl-users
CURLE_COULDNT_CONNECT after 120 requests
Date: Fri, 30 Apr 2010 13:29:12 +0530
I am working on a code which requires data to be sent for each URL. I used
following code to send the data. But after 120-130 requests CURL is throwing
CURL_SOCKET_BAD in connect::singleipconnect(..). It is failing at
verifyconnect(). It starts working again after 140 if i add delay for CURL
errors.
Code
---------------------------------------------------------------
static const char *urls[] = {
"http://www.xyz1.com",
"http://www.xyz2.com",
"http://www.xyz3.com",
"http://www.xyz4.com",
"http://www.xyz5.com",
};
#define URLsCOUNT sizeof(urls)/sizeof(char*) /* total number of transfers
to do */
for(int i=0;i<30;i++)
{
for(int j=0; j<URLsCOUNT ;j++)
{
sendData(urls[i],getData(i));
}
}
void sendData(char* url, char* data)
{
CURL* curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);
curl_easy_setopt(curl, CURLOPT_AUTOREFERER, true);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
curl_easy_setopt(curl, CURLOPT_LOCALPORTFUNCTION, getRandomPort);
curl_easy_setopt(curl, CURLOPT_LOCALPORTDATA, this);
curl_easy_setopt(curl, CURLOPT_LOCALPORTRANGE, (long) 511);
//cleanup
CURLcode curlRes=curl_easy_perform(curl);
curl_easy_cleanup(curl);
if (curlRes == CURLE_COULDNT_CONNECT){
//Got error and delay & retry
}
}
Sandeep M
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-04-30