Fix address resolution for cases where first result is not useful.

The socket connection logic always presumed the first returned result from
socket.getaddrinfo(...) is the target.  However it is not uncommon to be
listening IPv4 while ignore IPv6.  This code iterates through the return list
until one connects without a CONNECTION REFUSED error, if all fail, the
exception is rethrown.  `man getaddrinfo` demonstrates a similar use pattern
in C.