如何配置xmlrpc-c abyss服务器主机?
我正在使用 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;
}
I am using xmlrpc-c library (c++ version) to write a program. I find that there is no way to configure the xmlrpc server's host. I can only configure the port like below. Can anyone tell me how to configure the hostname for this server?
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;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个服务器,因此它侦听您运行它的计算机上给定端口上的连接。给它一个主机名没有多大意义。当然,您可以在客户端指定要连接的主机,请参阅此处。或者您正在谈论将服务器绑定到特定的网络接口?我认为图书馆不支持这一点。
编辑0:
我认为如果您需要侦听给定接口,您应该能够使用
socketFd
和socketBound
选项 - 创建您自己的套接字,将其绑定到任何内容,通过它到 API。这只是从他们的来源来看的,所以我不知道这是否真的有效。This is a server, so it listens for connections on the given port on the machine you are running it on. Giving it a hostname does not make much sense. You can, of course, specify a host to connect to on the client, see here. Or you are talking about binding the server to a particular network interface? I don't think the library supports that.
Edit 0:
I think you should be able to use the
socketFd
andsocketBound
options if you need to listen on given interface - create your own socket, bind it to whatever, pass it to the API. That's just from looking at their source, so I have no idea if this actually works.