import socket


def port_is_open(adr, timeout=1, attempts=1):
    """
    Returns `true` if the tcp address *ip*:*port* is reachable.

    Parameters:
        * adr
            The network address tuple of the target.
        * timeout
            Time in seconds waited until a connection attempt is
            considered to be failed.
        * attempts
            Number of port checks done until the *adr* is considered
            to be unreachable.
    """
    for i in range(attempts):
        s = socket.socket()
        s.settimeout(timeout)
        try:
            s.connect(adr)
        except Exception as err:
            pass
        else:
            return True
        finally:
            s.close()
    return False