private function connection_result($errno = null) {
        static $countfailures = array();
        $sess = sesskey();
        if (!array_key_exists($sess, $countfailures)) {
            $countfailures[$sess] = 0;
        }
        if ($errno !== null) {
            if ($errno == 0) {
                // reset count of failed connections
                $countfailures[$sess] = 0;
            } else if ($errno == 7 /*CURLE_COULDNT_CONNECT*/ || $errno == 9 /*CURLE_REMOTE_ACCESS_DENIED*/) {
                // problems with server
                $countfailures[$sess]++;
            }
        }
        return ($countfailures[$sess] < 3);
    }