cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Reuse ports

From: Joe Halpin <j.p.h_at_comcast.net>
Date: Mon, 08 Mar 2004 09:13:01 -0600

Tburhan wrote:
> Joe,
>
> At any given time, the node will execute a large number of curl_perform().
> That number could be 100, 1000, 10000, or even more. So when I reach
> certain limit, curl gives me code 28 (Resource Temporary Unavailable)
> and I basically had to wait for that TIME_WAIT to be able to send again.
> The default TIME_WAIT is quite long, I can't afford losing the
> opportunity to transfer data for that long. So perhaps, my question
> then, is it possible to adjust that TIME_WAIT? If it is, where can I do it?

The TIME_WAIT setting is system wide, and how to set it depends on the
OS you're using. You should be very careful about changing it though,
especially if you're making large numbers of connections in a short
period of time. The TIME_WAIT is there to prevent connections from
becoming confused with old data and acknowledgements.

Are all these connections coming from the same process? If so, you might
check first to see if you're not running out of file descriptors for
your process (check ulimit -a for the limit).

At any rate, using the same port number all the time for the client will
slow you down much more than what's happening now, assuming you're
connecting to the same remote host. If so, you'll wind up trying to make
the same connection (local host, local port, remote host, remote port)
before the TIME_WAIT period is over, and TCP just won't let you do that.

Joe
Received on 2004-03-08