[gsoap] SIGPIPE (Broken pipe) in client/standalone server
2008-12-03 14:55
357 查看
注: 在使用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
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
相关文章推荐
- How to use ASMCA in silent mode to configure ASM for a stand-alone server [ID 1068788.1]
- Spark系列(2)—A Standalone App in Scala
- Simple HTTP Server and Client in Python
- JAVA Client call gSOAP server
- VMware vCenter Converter Standalone Client 安装出错
- The Ex CS Grad Student: Running HQL from Python without using the Hive Standalone Server
- Item 17: Store newed objects in smart pointers in standalone statements.(Effective C++)
- How To Create A Client Server Application In Minutes[如何在几分钟的时间里编写一个客户机/服务器控制台程序]
- Embed client-side JavaScript in an ASP.NET 1.1 web page from server side code
- "Program received signal SIGPIPE, Broken pipe."解决
- VMware vCenter Converter Standalone Client在P2V后,再做V2V
- Simple HTTP Server and Client in Python
- 使用Selenium server standalone实现定时web自动化下载电影
- White Paper: Understanding the Relative Costs of Client Access Server Workloads in Exchange Server
- how to use a SQLite database in a standalone program with an HTML interface and VBScript as the programming language
- program received signal sigpipe broken pipe
- check sharepoint server is standalone or farm mode
- Multicast server and client in Python
- trac配置(stand-alone server)
- Java Socket Programming in Client/Server Applications - 转自 http://www.developer.com/