cURL / Mailing Lists / curl-users / Single Mail

curl-users

--local-port on Win32

From: Gisle Vanem <giva_at_bgnett.no>
Date: Mon, 30 Jan 2006 21:17:14 +0100

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 post.bgnett.no/.ssl

gives:
...
< HTTP/1.1 302 Found
< Date: Mon, 30 Jan 2006 19:42:15 GMT
< Server: Apache/1.3.27 (Unix) PHP/4.2.3
< Location: https://post.bgnett.no/.ssl
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=iso-8859-1
...
Connection #0 to host post.bgnett.no left intact
* Issue another request to this URL: 'https://post.bgnett.no/.ssl'
* Couldn't find host post.bgnett.no in the _netrc file, using defaults
* About to connect() to post.bgnett.no port 443
* Trying 194.54.96.133... bind failure: Address already in use
* couldn't connect to host

------------------

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

Another variation using '--local-port 22222-22223' says:

* About to connect() to post.bgnett.no port 443
* Trying 194.54.96.133... 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. Does OpenSSL allow specifying the local port?

--gv
Received on 2006-01-30