original_string: public function readTo($prompt) {
  
          if (!$this->socket) {
              throw new \Exception("Telnet connection closed");
          }
  
          // clear the buffer 
          $this->clearBuffer();
  
          $until_t = time() + $this->timeout;
          do {
              // time's up (loop can be exited at end or through continue!)
              if (time() > $until_t) {
                  throw new \Exception("Couldn't find the requested : '$prompt' within {$this->timeout} seconds");
              }
  
              $c = $this->getc();
  
              if ($c === false) {
                  throw new \Exception("Couldn't find the requested : '" . $prompt . "', it was not in the data returned from server: " . $this->buffer);
              }
  
              // Interpreted As Command
              if ($c == $this->IAC) {
                  if ($this->negotiateTelnetOptions()) {
                      continue;
                  }
              }
  
              // append current char to global buffer           
              $this->buffer .= $c;
              if ($this->debug_mode === 1 || $this->debug_mode === 3) {
                  $this->log($c);
              }
  
              // we've encountered the prompt. Break out of the loop
              if ((substr($this->buffer, strlen($this->buffer) - strlen($prompt))) == $prompt) {
                  return true;
              }
          } while ($c != $this->NULL || $c != $this->DC1);
      }
code: public function readTo($prompt) {
  
          if (!$this->socket) {
              throw new \Exception("Telnet connection closed");
          }
  
          // clear the buffer 
          $this->clearBuffer();
  
          $until_t = time() + $this->timeout;
          do {
              // time's up (loop can be exited at end or through continue!)
              if (time() > $until_t) {
                  throw new \Exception("Couldn't find the requested : '$prompt' within {$this->timeout} seconds");
              }
  
              $c = $this->getc();
  
              if ($c === false) {
                  throw new \Exception("Couldn't find the requested : '" . $prompt . "', it was not in the data returned from server: " . $this->buffer);
              }
  
              // Interpreted As Command
              if ($c == $this->IAC) {
                  if ($this->negotiateTelnetOptions()) {
                      continue;
                  }
              }
  
              // append current char to global buffer           
              $this->buffer .= $c;
              if ($this->debug_mode === 1 || $this->debug_mode === 3) {
                  $this->log($c);
              }
  
              // we've encountered the prompt. Break out of the loop
              if ((substr($this->buffer, strlen($this->buffer) - strlen($prompt))) == $prompt) {
                  return true;
              }
          } while ($c != $this->NULL || $c != $this->DC1);
      }
code_tokens: public function readTo ( $ prompt ) { if ( ! $ this -> socket ) { throw new \ Exception ( "Telnet connection closed" ) ; } // clear the buffer  $ this -> clearBuffer ( ) ; $ until_t = time ( ) + $ this -> timeout ; do { // time's up (loop can be exited at end or through continue!) if ( time ( ) > $ until_t ) { throw new \ Exception ( "Couldn't find the requested : '$prompt' within {$this->timeout} seconds" ) ; } $ c = $ this -> getc ( ) ; if ( $ c === false ) { throw new \ Exception ( "Couldn't find the requested : '" . $ prompt . "', it was not in the data returned from server: " . $ this -> buffer ) ; } // Interpreted As Command if ( $ c == $ this -> IAC ) { if ( $ this -> negotiateTelnetOptions ( ) ) { continue ; } } // append current char to global buffer            $ this -> buffer .= $ c ; if ( $ this -> debug_mode === 1 || $ this -> debug_mode === 3 ) { $ this -> log ( $ c ) ; } // we've encountered the prompt. Break out of the loop if ( ( substr ( $ this -> buffer , strlen ( $ this -> buffer ) - strlen ( $ prompt ) ) ) == $ prompt ) { return true ; } } while ( $ c != $ this -> NULL || $ c != $ this -> DC1 ) ; }
docstring: Reads characters from the socket and adds them to command buffer.
  Handles telnet control characters. Stops when prompt is ecountered.
  
  @param string $prompt
  @return boolean
docstring_tokens: Reads characters from the socket and adds them to command buffer . Handles telnet control characters . Stops when prompt is ecountered .