import socket


def ping_tcp_port(host, port, timeout=5):
    """Ping a TCP host/port with a configurable timeout.

    It's not really a ping but a little connection attempt to see if the
    port is open and listened. The timeout is useful when there is a kind
    of firewall between.

    No Exception are raised in any case.

    Args:
        host (string): the hostname/ip to ping.
        port (int): the TCP port to ping.
        timeout (int): timeout in seconds.

    Returns:
        boolean: True if the port is open and listened.

    """
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.settimeout(timeout)
    try:
        result = sock.connect_ex((host, port))
        if result == 0:
            sock.close()
            return True
    except Exception:
        pass
    return False