import socket


def check_for_remote_listening_port(port, ip_addr="127.0.0.1"):
    """
    Tries to connect to a port to see if port is listening.
    :param port: Port being tested.
    :param ip_addr: IP address of the host being connected to.
    :return: True if connection to the port is established.
    """
    port_listening = True
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    try:
        sock.connect((ip_addr, port))
    except socket.error as err:
        # Socket error: Connection refused, error code 10061
        if err.errno == 10061:
            port_listening = False
    finally:
        sock.close()
    return port_listening