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 It should not, but I rather switch this off explicitly and then restore to what it was. I have seen this causing issues, I don't want some Ruby gem to switch this global by accident, etc.