public function onStreamRead(IO_Stream_Interface $stream, $bytes_read) { $this->_read_buffer->rewind(); $data = $this->_read_buffer->read(); $echo_len = $this->_echo_buffer->getLength(); if ($echo_len) { $data_len = strlen($data); if ($data_len < $echo_len) { $echo_len = $data_len; } $this->_echo_buffer->rewind(); $echo = $this->_echo_buffer->read($echo_len); $possible_echo = substr($data, 0, $echo_len); if ($possible_echo == $echo) { $data = substr($data, $echo_len); $this->_read_buffer->release($echo_len); $this->_echo_buffer->release($echo_len); } } $success = Telnet_Listener_Interface::SUCCESS; if ($success === $this->_listener->onTelnetPromt($this, $data)) { $length = strlen($data); $this->_read_buffer->release($length); } }