在编写windows c++版本的thrift 代码时,代码完成后,启动服务端,报错:Thrift: getaddrinfo 10093: 应用程序没有调用WSAStartup, 或者WSAStartup 失败。
解决方法:
在server端main函数中添加下面红色字体,即能正常运行
int main(int argc, char **argv) {
int port = 9090;
TWinsockSingleton::create();
shared_ptr<ServHandler> handler(new ServHandler());
shared_ptr<TProcessor> processor(new ServProcessor(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();
return 0;
}