'Build the OK SOCKS5 connection response'

def _build_response(self):

    (addr, port) = self.client_socket.getsockname()[:2]
    family = self.client_socket.family
    addr_str = socket.inet_pton(family, addr)
    if (family == socket.AF_INET):
        atype = chr(SocksConnection.ATYPE_IP)
    elif (family == socket.AF_INET6):
        atype = chr(SocksConnection.ATYPE_IP6)
    else:
        raise ValueError('Bad    socket    family')
    return ((('\x05\x00\x00' + atype) + addr_str) + struct.pack('!H', port))
