【发布时间】:2016-05-14 10:10:49
【问题描述】:
我是 Apache Thrift 的新手,我正在一个大学项目中,我需要将 C++ 服务器和 C# 客户端与 Apache Thrift 连接。
当它们在同一台 PC 上运行时,我可以连接它们。从一开始,本教程包含:
TTransport transport = new TSocket("localhost",9090);
TProtocol protocol = new TBinaryProtocol(transport);
Analizador.Client client = new Analizador.Client(protocol);
但我需要将它们分开,一个在运行 Linux 的 PC 中,另一个在运行 Windows 的 PC 中,因此它们都在同一个网络中。我需要如何或在哪里进行配置才能实现这一点?
更具体地说:主 PC 运行 Windows,内部是一个运行 Ubuntu 16.04 的虚拟机,它有一个正在运行的 C++ 服务器:
int port = 9090;
shared_ptr<AnalizadorHandler> handler(new AnalizadorHandler());
shared_ptr<TProcessor> processor(new AnalizadorProcessor(handler));
shared_ptr<TServerTransport> serverTransport(new TServerSocket(port));
shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());
shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
TSimpleServer server(processor, serverTransport, transportFactory, protocolFactory);
server.serve();
【问题讨论】:
标签: thrift