gSoap:如何正常关闭webservice应用程序? [英] gSoap: how to gracefully shutdown the webservice application?

查看:593
本文介绍了gSoap:如何正常关闭webservice应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用gSoap编写webservice。它作为控制台应用程序运行。在所有gSoap示例中,我看到,即使在多线程版本中,请求也以无限循环的形式调用,如for(;;;)。



但是如何让我的web服务优雅地终止,例如,用户按下控制台上的空间?



优选地:


  1. 停止接受新的连接;

  2. 服务现有的;

  3. 退出应用程序


解决方案

a href =http://www.cs.fsu.edu/~engelen/soapdoc2.html#tth_sEc7.2.4 =nofollow> 7.2.4如何创建多线程独立服务在文档中有用于编写接受循环的示例代码。


  1. 停止接受新的连接:



    线程需要在完成后通知您,所以当活动客户端的数量为零时,您可以退出。


  2. 退出应用程序:



    1. 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:

      1. stop accepting new connections;
      2. Serve existing ones;
      3. Exit from application

      解决方案

      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.

      1. stop accepting new connections:

        Leave the loop so you stop calling accept.

      2. 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.)

      3. Exit from application:

      这篇关于gSoap:如何正常关闭webservice应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆