Java C++;Thrift:我可以将TFramedTransportFactory与TThreadedServer一起使用吗?
下面的代码可以工作Java C++;Thrift:我可以将TFramedTransportFactory与TThreadedServer一起使用吗?,java,c++,thrift,transport,Java,C++,Thrift,Transport,下面的代码可以工作 shared_ptr<TSocket> socket(new TSocket(serverName, serverPort)); shared_ptr<TTransport> transport(new TFramedTransport(socket)); shared_ptr<protocol::TProtocol> protocol( new protocol::TBinaryProtocol(transport)); sha
服务器:shared_ptr<TSocket> socket(new TSocket(serverName, serverPort)); shared_ptr<TTransport> transport(new TFramedTransport(socket)); shared_ptr<protocol::TProtocol> protocol( new protocol::TBinaryProtocol(transport)); shared_ptr<ThriftClient> client(new SampleServiceClient(protocol)); transport->open(); client->sampleThriftMethod();
客户:// SampleServiceHandler is a class that implements // the Thrift service methods. shared_ptr handler(new SampleServiceHandler); shared_ptr processor(new SampleServiceProcessor(handler)); shared_ptr serverTransport( new transport::TServerSocket(serverPort)); shared_ptr transportFactory( new transport::TFramedTransportFactory()); shared_ptr protFactory( new protocol::TBinaryProtocolFactory()); shared_ptr server(new server::TThreadedServer( processor, serverTransport, transportFactory, protFactory)); server->serve();
然而,当我在服务器端使用TBufferedTransportFactory而不是TFramedTransportFactory时,它也可以工作。我找到的使用TThreadedServer的唯一示例代码使用TBufferedTransportFactory,因此我想知道TFramedTransportFactory是否有问题
shared_ptr套接字(新的TSocket(serverName,serverPort)); 共享ptr传输(新的TFramedTransport(套接字)); 共享ptr协议( 新协议:TBinaryProtocol(传输协议); 共享ptr客户端(新SampleServiceClient(协议)); 传输->打开(); 客户端->sampleThriftMethod();
我之所以切换它是因为我希望使用TFRAMDeDelphi的java客户端使用服务器与java TStRead DeloServer进行对话,也可以使用服务器与C++ C++ TestAdDeServer通信。(类似于Java TThreadedSelectorServer)
在其他情况下,它是可选的,但可以工作。在使用TThreadedServer的示例中没有使用它 仍然-你的设置没有问题