if ($p === false) { return; } // Вырежем команду $cmd = substr($Connection->ReadBUF, 0, $p); $Connection->ReadBUF = substr($Connection->ReadBUF, $p + 1); if (trim($cmd) == 'quit') { //echo "quit detach\r\n"; $this->ConnectionManager->detach($Connection); } else { $this->WriteToAll($Connection->id . ":" . $cmd . "\r\n"); } } } class TestHTTPProtocol extends tSocketProtocol { function onData($Connection) { $Connection->Write("HTTP/1.1 200 OK\r\nContenth-type: text/html; charset=UTF-8\r\n\r\nOK"); $Connection->Close(); } } $server = new tSocketServer(); $server->attachProtocol(new MyProtocol()); // accepting connections on port 4111 and 4112 if ($server->Bind('127.0.0.1', 4111)) { if ($server->Bind('127.0.0.1', 4112)) { echo "Binded\n"; $server->Start(); } }