fix crash when #connect was unsuccessful

we tried to read the version, and the (dead) socket returned nil.