Handle WSAEADDRINUSE more nicely
Previously Vidalia reported "Tor exited unexpectedly" if Tor was already running (for example the Vidalia Bundle) and one started TBB, because both were using the same Socks (9050) and Control (9051) port.
With Vidalia and Tor already running the latest Tor in the stable TBB (tor-browser-2.3.25-1_en-US) behaves the same, at least on Windows.
Installed: ControlPort:127.0.0.1:9051 (set by Vidalia) SocksPort:127.0.0.1:9001 (manually set)
TBB: ControlPort:127.0.0.1:9052 (manually set) SocksPort:127.0.0.1:9050 (manually set, to work with Tor Browser) SocksPort:127.0.0.1:9001 (manually set)
If one of them is running and the other is launched Vidalia (of the one that's about to be launched) reports that Tor exited unexpectedly and the log says:
[Warning] Could not bind to 127.0.0.1:9001: Address already in use [WSAEADDRINUSE ]. Is Tor already running? [Warning] Failed to parse/validate config: Failed to bind one of the listener ports. [Error] Reading config failed--see warnings above.
While I assume that it's better to exit if the control port is unavailable (if not AUTO, because I guess it would work in that case) I wonder if Tor should just warn that it can't bind to an address if there are other successful connections.
I'd like to have Tor keep running (if it can bind at least one SocksPort successfully) and (if necessary) Vidalia report (pop-up) "WARNING, could not bind to $address! Please check if Tor is already running and change your (SOCKS) configuration."
I assume that Tor behaves the same if the (SOCKS) port is taken by another application.
This ticket assumes that Tor is supposed to exit if it fails to bind to a socks port. If it's a bug, you can change the type or I file a new ticket.
If it doesn't work, say why (short) and select "invalid".
"Please change your socks!" (Choose the error message with care :))