processor = new $processor($handle); $this->{$this->type}(); } # socket private function socket() { $transportFactory = new TBufferedTransportFactory(); $protocolFactory = new TBinaryProtocolFactory(true, true); $transport = new TServerSocket($this->host, $this->port); $server = new TForkingServer($this->processor, $transport, $transportFactory, $transportFactory, $protocolFactory, $protocolFactory); $server->serves($this->process); } # php stream public function stream() { if (php_sapi_name() == 'cli') { echo PHP_EOL; } $transport = new TBufferedTransport(new TPhpStream(TPhpStream::MODE_R | TPhpStream::MODE_W)); $protocol = new TBinaryProtocol($transport,true,true); $transport->open(); $this->processor->process($protocol, $protocol); $transport->close(); } }