The whole block is an exercise in determining whether we're connected; `ENOTCONN` is the exception we *expect* (if there's no exception, then we're already connected, and if there's a different exception, then we have a problem). I'll refactor and more liberally comment for clarity.