Fix a couple of bugs with TCP connection handling.
Plumb ssh connection status through to libssh.

This allows fast-failure when, e.g., connecting to a closed port.