cURL / Mailing Lists / curl-users / Single Mail


Re: --local-port on Win32

From: Daniel Stenberg <>
Date: Mon, 30 Jan 2006 23:07:23 +0100 (CET)

On Mon, 30 Jan 2006, Gisle Vanem wrote:

> Looks like whenever curl uses this option, Winsock denies the
> 2nd bind() from working.... because the 1st socket is still in TIME_WAIT I
> assume. E.g. this command:
> curl -v --local-port 22222 -L

Not only on windows, that is likely to happen everywhere. I actually
considered setting the default "range" to something other than 1 just for that

> So libcurl should maybe use the SO_REUSEADDR/PORT to fix this?

Perhaps. I'm not sure if that would have any other side effects though...

> Another variation using '--local-port 22222-22223' says:
> * About to connect() to port 443
> * Trying Bind to local port 22222 failed, trying next
> * Local port: 22223
> I think libcurl is lying here. Using a netstat tool (ActivePorts by
> Sysinternals), doesn't list port 22223 in use.

Oh! Then something is wrong... I should do some further testing on my own too
and see that it works fine on a few unix flavours.

> Does OpenSSL allow specifying the local port?

OpenSSL doesn't care about such details I would guess, as we hand over an
already existing and connected socket to OpenSSL to play with...

  Commercial curl and libcurl Technical Support:
Received on 2006-01-30