import socket


def tcp_port_open_locally(port):
    """
    Returns True if the given TCP port is open on the local machine
    """
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    result = sock.connect_ex(("127.0.0.1", port))
    return result == 0