def METHOD_NAME(self, direction):
    """
    Tests:
        >>> l = listen()
        >>> r = remote('localhost', l.lport)
        >>> r.connected()
        True
        >>> l.close()
        >>> time.sleep(0.1) # Avoid race condition
        >>> r.connected()
        False
    """
    # If there's no socket, it's definitely closed
    if not self.sock:
        return False
    # If we have noticed a connection close in a given direction before,
    # return fast.
    if self.closed.get(direction, False):
        return False
    # If a connection is closed in all manners, return fast
    if all(self.closed.values()):
        return False
    # Use poll() to determine the connection state
    want = {
        'recv': select.POLLIN,
        'send': select.POLLOUT,
        'any':  select.POLLIN | select.POLLOUT,
    }[direction]
    poll = select.poll()
    poll.register(self, want | select.POLLHUP | select.POLLERR)
    for fd, event in poll.poll(0):
        if event & select.POLLHUP:
            self.close()
            return False
        if event & select.POLLIN:
            return True
        if event & select.POLLOUT:
            return True
    return True