src/sb/Telnet.php
public function negotiateTelnetOptions() {

        $c = $this->getc();

        if ($c != $this->IAC) {

            if (($c == $this->DO) || ($c == $this->DONT)) {

                $opt = $this->getc();
                fwrite($this->socket, $this->IAC . $this->WONT . $opt);
            } else if (($c == $this->WILL) || ($c == $this->WONT)) {

                $opt = $this->getc();
                fwrite($this->socket, $this->IAC . $this->DONT . $opt);
            } else {
                throw new \Exception('Error: unknown control character ' . ord($c));
            }
        } else {
            throw new \Exception('Error: Something Wicked Happened');
        }

        return true;
    }
public function negotiateTelnetOptions() {

        $c = $this->getc();

        if ($c != $this->IAC) {

            if (($c == $this->DO) || ($c == $this->DONT)) {

                $opt = $this->getc();
                fwrite($this->socket, $this->IAC . $this->WONT . $opt);
            } else if (($c == $this->WILL) || ($c == $this->WONT)) {

                $opt = $this->getc();
                fwrite($this->socket, $this->IAC . $this->DONT . $opt);
            } else {
                throw new \Exception('Error: unknown control character ' . ord($c));
            }
        } else {
            throw new \Exception('Error: Something Wicked Happened');
        }

        return true;
    }
public function negotiateTelnetOptions ( ) { $ c = $ this -> getc ( ) ; if ( $ c != $ this -> IAC ) { if ( ( $ c == $ this -> DO ) || ( $ c == $ this -> DONT ) ) { $ opt = $ this -> getc ( ) ; fwrite ( $ this -> socket , $ this -> IAC . $ this -> WONT . $ opt ) ; } else if ( ( $ c == $ this -> WILL ) || ( $ c == $ this -> WONT ) ) { $ opt = $ this -> getc ( ) ; fwrite ( $ this -> socket , $ this -> IAC . $ this -> DONT . $ opt ) ; } else { throw new \ Exception ( 'Error: unknown control character ' . ord ( $ c ) ) ; } } else { throw new \ Exception ( 'Error: Something Wicked Happened' ) ; } return true ; }
Telnet control character magic

@param string $command Character to check
@return boolean
Telnet control character magic