src/PTel.php
private function _negotiateDo($cmd) {
        switch ($cmd) {
            case TEL_TTYPE: // Send terminal type
                $term = (binary) $this->terminal_type;
                return $this->send(TEL_IAC.TEL_SUB.TEL_TTYPE.TEL_BIN.$term.
                            TEL_IAC.TEL_SUBEND,false);
            case TEL_XDISPLOC: // Send display location
                $hostname = (binary) php_uname('n').':0.0';
                return $this->send(TEL_IAC.TEL_SUB.TEL_XDISPLOC.TEL_BIN.$hostname.
                            TEL_IAC.TEL_SUBEND, false);
            case TEL_NEWENV: // Send new environment name
                $env = (binary) 'DISPLAY ' . php_uname('n'). ':0.0';
                return $this->send(TEL_IAC.TEL_SUB.TEL_NEWENV.TEL_BIN.$env.
                            TEL_IAC.TEL_SUBEND, false);
            case TEL_TSPEED: // Send terminal speed
                $tspeed = (binary) $this->terminal_speed_in . ','. $this->terminal_speed_out;
                return $this->send(TEL_IAC.TEL_SUB.TEL_TSPEED.TEL_BIN.$tspeed.
                            TEL_IAC.TEL_SUBEND, false);
            case TEL_NAWS: // Negotiate about window size
                $null = chr(0);
                $height = chr($this->window_size_height);
                $width = chr($this->window_size_width);
                return $this->send(TEL_IAC.TEL_SUB.TEL_NAWS.$null.$width.$null.$height.
                    TEL_IAC.TEL_SUBEND, false);
            case TEL_GA:
                break;
            case TEL_ECHO: // This is workaround for some strange thing
                return $this->send(TEL_IAC.TEL_WONT.TEL_ECHO, false);
            default: // In case we didn't implement - tell that we will don't
                     // use this option
                return $this->send(TEL_IAC.TEL_DONT.$cmd, false);
        }
    }
private function _negotiateDo($cmd) {
        switch ($cmd) {
            case TEL_TTYPE: // Send terminal type
                $term = (binary) $this->terminal_type;
                return $this->send(TEL_IAC.TEL_SUB.TEL_TTYPE.TEL_BIN.$term.
                            TEL_IAC.TEL_SUBEND,false);
            case TEL_XDISPLOC: // Send display location
                $hostname = (binary) php_uname('n').':0.0';
                return $this->send(TEL_IAC.TEL_SUB.TEL_XDISPLOC.TEL_BIN.$hostname.
                            TEL_IAC.TEL_SUBEND, false);
            case TEL_NEWENV: // Send new environment name
                $env = (binary) 'DISPLAY ' . php_uname('n'). ':0.0';
                return $this->send(TEL_IAC.TEL_SUB.TEL_NEWENV.TEL_BIN.$env.
                            TEL_IAC.TEL_SUBEND, false);
            case TEL_TSPEED: // Send terminal speed
                $tspeed = (binary) $this->terminal_speed_in . ','. $this->terminal_speed_out;
                return $this->send(TEL_IAC.TEL_SUB.TEL_TSPEED.TEL_BIN.$tspeed.
                            TEL_IAC.TEL_SUBEND, false);
            case TEL_NAWS: // Negotiate about window size
                $null = chr(0);
                $height = chr($this->window_size_height);
                $width = chr($this->window_size_width);
                return $this->send(TEL_IAC.TEL_SUB.TEL_NAWS.$null.$width.$null.$height.
                    TEL_IAC.TEL_SUBEND, false);
            case TEL_GA:
                break;
            case TEL_ECHO: // This is workaround for some strange thing
                return $this->send(TEL_IAC.TEL_WONT.TEL_ECHO, false);
            default: // In case we didn't implement - tell that we will don't
                     // use this option
                return $this->send(TEL_IAC.TEL_DONT.$cmd, false);
        }
    }
private function _negotiateDo ( $ cmd ) { switch ( $ cmd ) { case TEL_TTYPE : // Send terminal type $ term = ( binary ) $ this -> terminal_type ; return $ this -> send ( TEL_IAC . TEL_SUB . TEL_TTYPE . TEL_BIN . $ term . TEL_IAC . TEL_SUBEND , false ) ; case TEL_XDISPLOC : // Send display location $ hostname = ( binary ) php_uname ( 'n' ) . ':0.0' ; return $ this -> send ( TEL_IAC . TEL_SUB . TEL_XDISPLOC . TEL_BIN . $ hostname . TEL_IAC . TEL_SUBEND , false ) ; case TEL_NEWENV : // Send new environment name $ env = ( binary ) 'DISPLAY ' . php_uname ( 'n' ) . ':0.0' ; return $ this -> send ( TEL_IAC . TEL_SUB . TEL_NEWENV . TEL_BIN . $ env . TEL_IAC . TEL_SUBEND , false ) ; case TEL_TSPEED : // Send terminal speed $ tspeed = ( binary ) $ this -> terminal_speed_in . ',' . $ this -> terminal_speed_out ; return $ this -> send ( TEL_IAC . TEL_SUB . TEL_TSPEED . TEL_BIN . $ tspeed . TEL_IAC . TEL_SUBEND , false ) ; case TEL_NAWS : // Negotiate about window size $ null = chr ( 0 ) ; $ height = chr ( $ this -> window_size_height ) ; $ width = chr ( $ this -> window_size_width ) ; return $ this -> send ( TEL_IAC . TEL_SUB . TEL_NAWS . $ null . $ width . $ null . $ height . TEL_IAC . TEL_SUBEND , false ) ; case TEL_GA : break ; case TEL_ECHO : // This is workaround for some strange thing return $ this -> send ( TEL_IAC . TEL_WONT . TEL_ECHO , false ) ; default : // In case we didn't implement - tell that we will don't // use this option return $ this -> send ( TEL_IAC . TEL_DONT . $ cmd , false ) ; } }
Telnet DO negotiaion

@param    char   $cmd    Binary representation of command char

@throws   SocketClientException   On socket communication error
@return   int                     Bytes written
Telnet DO negotiaion