cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Couldn't Connect Error - Address already in use

From: Alfred Gebert <alfred.gebert_at_gmail.com>
Date: Mon, 12 Jul 2010 17:21:43 +0200

On Wed, Jul 7, 2010 at 4:58 PM, Adam Kellas <Adam.Kellas_at_gmail.com> wrote:
> On 7/7/2010 9:49 AM, Alfred Gebert wrote:
>>
>> At least this is a workaround. Perhaps I can modify my real codebase too.
>
> It's not a workaround, it's the way libcurl is intended to be used. Let's
> hope you can make the same change to your codebase.
>
Yes, you are right. I should really call
curl_easy_init/curl_easy_cleanup only once.

But running my tests it worked with Apache httpd (HTTP/1.1) but not
with my own server using HTTP/1.0 without pipelining. For the 8000
request libcurl has to open 8000 socket connections.

Now I googled again and found the answer:

libcurl can't create additional outgoing TCP/IP connections because it
runs out of available port numbers for the IP address.
On Windows the default limitation is 5000 - 1024 open sockets (5000 is
the default max user port setting and the first 1024 ports are
reserved).

You can increase the default maximum socket value in the registry:

    * Start Registry Editor (regedit.exe). Locate the following key in
the registry:

      HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters

    * Add or change the following registry value:
      Value Name: MaxUserPort Data Type: REG_DWORD Value: 60000
      Valid Range: 5000-65534 (decimal) Default: 0x1388 (5000 decimal)

    * Reboot the machine.

Microsoft description of MaxUserPort:
http://technet.microsoft.com/en-us/library/cc938196.aspx

Microsoft Exchange 2003 e. g. changes MaxUserPort to 60000
http://technet.microsoft.com/en-us/library/aa995661%28EXCHG.80%29.aspx.
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-07-12