gSoap:如何正常关闭webservice应用程序? [英] gSoap: how to gracefully shutdown the webservice application?
问题描述
我使用gSoap编写webservice。它作为控制台应用程序运行。在所有gSoap示例中,我看到,即使在多线程版本中,请求也以无限循环的形式调用,如for(;;;)。
但是如何让我的web服务优雅地终止,例如,用户按下控制台上的空间?
优选地:
- 停止接受新的连接;
- 服务现有的;
- 退出应用程序
a href =http://www.cs.fsu.edu/~engelen/soapdoc2.html#tth_sEc7.2.4 =nofollow> 7.2.4如何创建多线程独立服务在文档中有用于编写接受循环的示例代码。
-
停止接受新的连接:
线程需要在完成后通知您,所以当活动客户端的数量为零时,您可以退出。
-
退出应用程序:
- stop accepting new connections;
- Serve existing ones;
- Exit from application
stop accepting new connections:
Leave the loop so you stop calling accept.
Serve existing ones:
The threads need to inform you when they are finished, so you can exit when the number of active clients is zero. (boost::thead_group has a join_all which does exactly that.)
Exit from application:
I'm using gSoap to write a webservice. It's running as a console application. In all gSoap examples I see, that requests are dispatched in infinite loop like for(;;;) even in multi-threaded version.
But how can I make my webservice to terminate gracefully when, say, user presses space on the console?
Preferably:
The section 7.2.4 How to Create a Multi-Threaded Stand-Alone Service in the documentation has example code for writing an accept loop. You need to write your own accept loop and add signal handling so it responds to Ctrl-C.
这篇关于gSoap:如何正常关闭webservice应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!