cURL / Mailing Lists / curl-users / Single Mail


--local-port on Win32

From: Gisle Vanem <>
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

< 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:
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=iso-8859-1
Connection #0 to host left intact
* Issue another request to this URL: ''
* Couldn't find host in the _netrc file, using defaults
* About to connect() to port 443
* Trying 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 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. Does OpenSSL allow specifying the local port?

Received on 2006-01-30