Server_Socket=@fsockopen($Host, $Port, $Error_Number, $Error_String); if (!$this->Server_Socket) { $this->Server_Error_Number=$Error_Number; $this->Server_Error_String=$Error_String; } else socket_set_timeout($this->Server_Socket, $TimeOut); } function Beenden() { if ($this->Server_Socket) { If (fclose($this->Server_Socket)) { $this->Server_Socket=NULL; return 1; } else return 0; } else return 0; } function Schreiben($Command) { if ($this->Server_Socket) { $Replace=chr(255); $Command=str_replace($Replace, $Replace.$Replace, $Command); if (@fwrite($this->Server_Socket, $Command)) return 1; else return 0; } else return 0; } function Lesen($Bis) { if ($this->Server_Socket) { UnSet($String); $Array['IAC']=chr(255); $Array['DONT']=chr(254); $Array['DO']=chr(253); $Array['WONT']=chr(252); $Array['WILL']=chr(251); $Array['NULL']=chr(0); while (true) { $Charakter=fgetc($this->Server_Socket); if ($Charakter===false) return $String; if ($Charakter=="\021") continue; if ($Charakter==$Array['NULL']) continue; if ($Charakter!=$Array['IAC']) { $String.=$Charakter; if ($Bis==(substr($String,strlen($String)-strlen($Bis)))) return $String; else continue; } $Charakter=fgetc($this->Server_Socket); if ($Charakter==$Array['IAC']) $String.=$Charakter; else { $Array['Opt']=fgetc($this->Server_Socket); if (($Charakter==$Array['DONT']) ||($Charakter==$Array['DO'])) fwrite($this->Server_Socket, $Array['IAC'].$Array['WONT'].$Array['Opt']); elseif (($Charakter==$Array['WONT']) || ($Charakter==$Array['WILL'])) fwrite($this->Server_Socket, $Array['IAC'].$Array['DONT'].$Array['Opt']); } } } else return 0; } }