public function waitFor($str, $maxtimeout = 10) {
        $timestart = time();
        $buff = '';
        while (true) {
            $buff .= $this->recvChr();
            $timerun = time() - $timestart;

            if (preg_match("/$str/", $buff, $matches)) {
                return true;
            }

            if ($timerun >= $maxtimeout) {
                throw new TelnetException("Could not find occurance [ $str ] within timeout");
            }
        }
        return false;
    }