[gsoap] SIGPIPE (Broken pipe) in client/standalone server

  注: 在使用Gsoap时,避免使用函数重载,否则会出现一些意想不到的问题.

 

Whenever you use keep-alive support, a signal handler is required on Unix/Linux systems. In general, a SIGPIPE signal handler will prevent your application from terminating in case of a dropped connection. You can use a SIGPIPE handler or use the soap.socket_flags = MSG_NOSIGNAL or soap.connect_flags = SO_NOSIGPIPE (client-side) or soap.accept_flags = SO_NOSIGPIPE. These settings are not portable. Some Unix systems support MSG_NOSIGNAL while others support SO_NOSIGPIPE.

Keep-alive support has other VERY IMPORTANT effects on your service application when you deploy it in the "real world". You must use multi-threading, otherwise a long keep-alive session with a client will block the service from serving other clients. You should also set soap.recv_timeout and soap.send_timeout values, otherwise a client application can keep one thread busy indefinitely (however, it appears that OpenSSL does not support non-blocking sockets, so OpenSSL may not work in that case. I am working on a fix). Finally, the number of requests served per keep-alive connection is limited to 100 (SOAP_MAXKEEPALIVE in stdsoap2.h, compile with -DSOAP_MAXKEEPALIVE=X to change this).Web servers use counters to limit the number of calls so that threads will eventually be released to avoid clients from holding a thread indefinitely. This means that sessions that exceed 100 calls will be closed by the gSOAP service. This is the cause of your SIGPIPE.

Remember that your application should never rely on keep-alive to implement stateful sessions. A client or service can always close a keep-alive connection at any time or even not support it. You should use cookies or SOAP headers to implement transaction control for stateful sessions. An example is implemented in the factory client and service in the package. SOAP headers are used to exchange object handles.

 

  for example:

    

      soap.socket_flags = MSG_NOSIGNAL;    // in linux

      soap.accept_flags = NOSIGPIPE;               // other OS

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值