我正在编写一些 dll(在 MSVC++2008 中的 Windows 上),它提供了一些作为 xmlrpc 服务器的功能。为了实现 xmlrpc 服务器,我使用 xmlrpc-c 库。
我可以通过一些不同的方式启动 xmlrpc 服务器。更有趣的是:
- run method - 这将永远运行 xmlrpc 服务器,因此 dll 无法控制,直到服务器未终止。
- runOnce method - 这将仅运行 xmlrpc 服务器来处理一个 RPC。如果没有请求,它将等待。
我无法长时间控制dll。我需要处理一些 RPC 并将控制权交还给使用 dll 的程序。当 dll 再次获得控制权时,处理下一个 RPC。
runOnce 看起来没问题。但有可能没有 RPC 可以处理,而它会等待 RPC。这是 Not Acceptable 。
还有一个异常(exception):
runOnce aborts waiting for a connection request and returns immediately if the process receives a signal. Note that unless you have a handler for that signal, the signal will probably kill the whole process, so set up a signal handler — even one that does nothing — if you want to exploit this. But before Xmlrpc-c 1.06 (June 2006), signals have no effect — there is no way to make runOnce abort the wait and return.
我可以使用它作为解决方法来恢复对 dll 的控制吗?是否可以从dll向自己发送信号?它在 Windows 上如何工作?
或者也许这个问题有更好的解决方案?
最佳答案
Windows 中不存在信号(使 Xmlrpc-c 库调用提前中止的信号)。
最好的解决方案是为服务器创建新线程。
关于c++ - dll中的xmlrpc服务器,向自己发送信号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4545830/