Check for writability when waiting for a socket to finish connecting.

This causes daemons that make an outgoing connection to immediately send the ID
message (or proxy handshake), as intended.