import socket


def is_reachable(address):
    """Tries to connect to the given address using a TCP socket.

    Returns True iff this is possible. Always closes the connection before
    returning.
    """

    try:
        sock = socket.create_connection(address, 1.0)
        sock.close()
    except IOError:
        return False

    return True