Example #1
0
 /**
  *
  * Negotiate Telnet Commands
  *
  */
 protected function _negotiateTelnetCommand()
 {
     //echo "\nnegotiateTelnetCommand \n";
     $c = $this->_socket->read(1);
     switch ($c) {
         case TEL_DO:
             $opt = $this->_socket->read(1);
             //echo "<<DO Option(" . ord($opt) . ")\n" ;
             switch ($opt) {
                 /*case TELOPT_TSPEED:
                 		echo "<<DO TSPEED\n";
                 		echo ">>WILL TSPEED\n";
                 		$this->_socket->write(TEL_IAC . TEL_WILL . $opt);
                 		break;*/
                 default:
                     //echo ">>WONT Option(" . ord($opt) . ")\n";
                     $this->_socket->write(TEL_IAC . TEL_WONT . $opt);
             }
             break;
         case TEL_DONT:
             $opt = $this->_socket->read(1);
             //echo "<<DONT Option(" . ord($opt) . ")\n" ;
             switch ($opt) {
                 default:
                     //echo ">>WONT Option(" . ord($opt) . ")\n";
                     $this->_socket->write(TEL_IAC . TEL_WONT . $opt);
             }
             break;
         case TEL_WILL:
             $opt = $this->_socket->read(1);
             //echo "<<WILL Handle Option(" . ord($opt) . ")\n" ;
             //echo ">>DONT Option(" . ord($opt) . ")\n";
             $this->_socket->write(TEL_IAC . TEL_DONT . $opt);
             break;
         case TEL_WONT:
             $opt = $this->_socket->read(1);
             //echo "<<WONT Option(" . ord($opt) . ")\n" ;
             //echo ">>DONT Option(" . ord($opt) . ")\n";
             $this->_socket->write(TEL_IAC . TEL_DONT . $opt);
             break;
             /*case TEL_SB:
              	$opt = $this->_socket->read(1);
              	switch ( $opt ) {
              		case TELOPT_TSPEED: 
              			echo "<<SB TSPEED(" . ord($opt) . ")\n";
              			//echo "<< Next " . $this->_socket->read(1);
              			echo "<< " . ord($this->_socket->read(1)) . "\n";
              			echo "<< " . ord($this->_socket->read(1)) . "\n";
              			echo "<< " . ord($this->_socket->read(1)) . "\n";
              			echo ">> IAC TEL_SB TELOPT_TSPEED TEL_SE";
              			break;	
              	}
              	
              	break;*/
         /*case TEL_SB:
          	$opt = $this->_socket->read(1);
          	switch ( $opt ) {
          		case TELOPT_TSPEED: 
          			echo "<<SB TSPEED(" . ord($opt) . ")\n";
          			//echo "<< Next " . $this->_socket->read(1);
          			echo "<< " . ord($this->_socket->read(1)) . "\n";
          			echo "<< " . ord($this->_socket->read(1)) . "\n";
          			echo "<< " . ord($this->_socket->read(1)) . "\n";
          			echo ">> IAC TEL_SB TELOPT_TSPEED TEL_SE";
          			break;	
          	}
          	
          	break;*/
         default:
             throw new SocketException("Unhandled Telnet Negotiation Command " . ord($c));
     }
 }
Example #2
0
 /**
  * testReset method
  *
  * @return void
  */
 public function testReset()
 {
     $config = ['persistent' => true, 'host' => '127.0.0.1', 'protocol' => 'udp', 'port' => 80, 'timeout' => 20];
     $anotherSocket = new Socket($config);
     $anotherSocket->reset();
     $expected = ['persistent' => false, 'host' => 'localhost', 'protocol' => 'tcp', 'port' => 80, 'timeout' => 30];
     $this->assertEquals($expected, $anotherSocket->config(), 'Reset should cause config to return the defaults defined in _defaultConfig');
 }