Source for file NS_Telnet_Handler.php
Documentation is available at NS_Telnet_Handler.php
* nanoserv handlers - Telnet protocol handler
* Copyright (C) 2004-2010 Vincent Negrier aka. sIX <six@aegis-corp.org>
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
* Require the nanoserv core
require_once "nanoserv-compat/nanoserv.php";
* Telnet protocol handler handler class
* Protocol options set by the remote party
private function Set_Remote_Option($type, $option) {
$this->Raw_Write(self::IAC . $type . $option);
protected function Raw_Write($data, $callback= false) {
return parent::Write($data, $callback);
public function Write($data, $callback= false) {
$data = str_replace(self::IAC, self::IAC . self::IAC, $data);
return parent::Write($data, $callback);
if (strpos($data, self::IAC) !== false) {
for ($a = 0; $a < $len; $a++ ) {
if ($data[$a] === self::IAC) {
$this->Set_Remote_Option($data[$a + 1], $data[$a + 2]);
* This event is called every time there is data received
|