我正在使用 xmlrpc-c 库(c++ 版本)编写程序。我发现无法配置 xmlrpc 服务器的主机。我只能像下面这样配置端口。谁能告诉我如何为此服务器配置主机名?
xmlrpc_c::registry myRegistry;
xmlrpc_c::defaultMethodPtr const XMLRPCMethodP(handler);
//myRegistry.addMethod("method", XMLRPCMethodP);
myRegistry.setDefaultMethod(XMLRPCMethodP);
webServer = new serverAbyss(xmlrpc_c::serverAbyss::constrOpt()
.registryP(&myRegistry)
.logFileName("/tmp/xmlrpc_log")
.portNumber(8183)
.uriPath("/")
); // Currently, there is no way to configure Host here.
try {
webServer->run();
} catch (std::exception &e) {
cout << e.what() << endl;
}
最佳答案
这是一个服务器,所以它监听您运行它的机器上给定端口上的连接。给它一个主机名没有多大意义。当然,您可以在客户端指定要连接的主机,请参阅 here .或者您正在谈论将服务器绑定(bind)到特定的网络接口(interface)?我认为图书馆不支持这一点。
编辑0:
如果你需要在给定的接口(interface)上监听,我认为你应该能够使用 socketFd
和 socketBound
选项 - 创建你自己的套接字,将它绑定(bind)到任何东西,通过它到 API。这只是查看它们的来源,所以我不知道这是否真的有效。
关于c++ - 如何配置xmlrpc-c深渊服务器主机?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6831515/