def _find_address_and_connect(self, addresses):
        """Find and connect to the appropriate address.

        :param addresses:
        :raises AMQPConnectionError: If no appropriate address can be found,
                                     raise an exception.
        :return:
        """
        for address in addresses:
            sock = self._create_socket(socket_family=address[0])
            try:
                sock.connect(address[4])
            except (socket.error, __HOLE__):
                continue
            return sock
        raise AMQPConnectionError('Could not connect to %s:%d'
                                  % (self._parameters['hostname'],
                                     self._parameters['port']))
dataset/ETHPy150Open eandersson/amqpstorm/amqpstorm/io.py/IO._find_address_and_connect