import socket


def is_server_alive(host, port):
    """
    Attempts to connect to a given host and port. If the connection is successful then True is returned. Otherwise,
    False is returned.

    :param host: the target host name or ip address.
    :param port: the target port.
    :return: True if the connection to the provided host and port is successful. False if the connection is refused.
    """
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    try:
        s.connect((host, port))
        s.shutdown(2)
        return True
    except ConnectionRefusedError:
        return False