Fix connection detection logic.

The fact that we have socket back from IO::select, does not necessarily
mean that mean that we can actually ready and/or write to it.

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
@lamont-granquist I wanted to group `Errno` and things having `StandardError` as parent together. I can fix this, if this is a problem.