def _setup_connection(self, peer):
    try:
        (af, socktype, proto, canonname, sa) = socket.getaddrinfo(peer[0], peer[1], 0, socket.SOCK_STREAM)[0]
        sock = socket.socket(af, socktype, proto)
        sock.connect(sa)
    except socket.error as e:
        raise socket.error(('Connection error (%s:%s)' % (peer[0], peer[1])), e)
    return sock
def _setup_connection(self, peer):
    try:
        (af, socktype, proto, canonname, sa) = socket.getaddrinfo(peer[0], peer[1], 0, socket.SOCK_STREAM)[0]
        sock = socket.socket(af, socktype, proto)
        sock.connect(sa)
    except socket.error as e:
        raise socket.error(('Connection error (%s:%s)' % (peer[0], peer[1])), e)
    return sock