curl-library
Re: Couldn't Connect Error - Address already in use
Date: Wed, 7 Jul 2010 12:21:35 +0200
On Wed, Jul 7, 2010 at 10:57 AM, Alfred Gebert <alfred.gebert_at_gmail.com> wrote:
> On Tue, Jul 6, 2010 at 7:10 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:
>> On Tue, 6 Jul 2010, Alfred Gebert wrote:
>>
>>> I am using libcurl 7.19.4 on Windows XP and I want to call a HTTP PUT
>>> operation around 8000 times. After about 4000 requests curl_easy_perform()
>>> returns with error 7 (CURLE_COULDNT_CONNECT, Couldn't Connect Error, Address
>>> already in use).
>>
>> While the reason sounds a bit strange, it certainly sounds as if you're
>> simply draining the resources from the target server so that you then can't
>> connect to it anymore. The error 7 is a failed TCP connection.
>>
>
> The target server is my own program serving SOAP requests. The client
> and the target server are running on the same machine.
> I have no errors on the target server.
>
> I will retest using Apache httpd as target server and running the
> libcurl program on Linux.
>
I retested it with a simpler program executing a HTTP GET.
The target server is Apache httpd on Linux. The libcurl client on
Windows XP fails again (result 7 of curl_easy_perform(). Running the
libcurl client on Linux (OpenSuse 11.2 x86) is fine.
So in my opinion there is a limitation of libcurl running on Windows XP.
If you want to run the program you have to change the target server URL.
#include <stdio.h>
#include <curl/curl.h>
size_t write_callback( void* Buffer, size_t BufferSize, size_t
BufferCount, void* Stream)
{
/* do nothing */
return( BufferSize * BufferCount);
}
int main(void)
{
CURL *curl;
CURLcode res;
/* In windows, this will init the winsock stuff */
curl_global_init(CURL_GLOBAL_ALL);
for( int i=0; i < 10000; i++)
{
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://gebert4.e2e.ch:1884/");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
res = curl_easy_perform(curl);
if( res != 0)
{
printf( "%d request failed: %d\n", i+1, res);
return -1;
}
/* simple progress bar */
printf( ".");
/* always cleanup */
curl_easy_cleanup(curl);
}
else
{
printf( "init failed\n");
return -2;
}
}
curl_global_cleanup();
return 0;
}
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-07-07