import socket


def is_port_open(port):
    """
    Checks if the port is open on localhost by creating a socket connection to it.
    :param port: The port as a number
    :return: True if open, false otherwise
    """
    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
        return sock.connect_ex(('127.0.0.1', port)) == 0