参考:http://www.cs.fsu.edu/~engelen/soapdoc2.html#tth_sEc19.19
gsoap就不用介绍了,是一个c/c++编写的可用于服务端与客户端的连接工具。
Socket connect, accept, send, and receive timeout values can be set to manage socket communication timeouts. The soap.connect_timeout, soap.accept_timeout, soap.send_timeout, and soap.recv_timeout attributes of the current gSOAP runtime context soap can be set to the appropriate user-defined socket send, receive, and accept timeout values. A positive value measures the timeout in seconds. A negative timeout value measures the timeout in microseconds (10−6 sec).
This will result in a timeout if no data can be send in 10 seconds and no data is received within 10 seconds after initiating a send or receive operation over the socket. A value of zero disables timeout, for example:
When a timeout occurs in send/receive operations, a SOAP_EOF exception will be raised ("end of file or no input"). Negative timeout values measure timeouts in microseconds, for example:
The macros improve readability. |
初始化gsoap后,然后就可以设置了。
在struct soap里面 是有很多参数的,具体可以参见 stdsoap2.h文件。。
只要
soap.send_timeout = 10;
soap.recv_timeout = 10;
就可以。。
因为gsoap使用的包装http协议。然后最主要的是socket传输,对于我们熟悉的socket传输,我们在非阻塞的情况下才能设置超时。(包括 连接超时 accetp_timeout, 发送超时 send_timeout, 以及接受超时 recv_timeout)。
转自:https://www.cnblogs.com/hcu5555/p/3707190.html
1.修改gsoap自动生成的代码才能进行超时设置(我这边访问web service的代码都是gsoap工具自动生成.根据wsdl接口)
2.找到生成的soapwwwsdlBindingProxy.cpp文件
3.找到你要设置超时的那个调用服务器的方法
4.找到该方法代码 struct soap *soap = this;
在该代码下添加如下三行代码(时间大小根据项目自行调整)
soap->recv_timeout = 2;//接受 (单位是秒)
soap->send_timeout = 2;//发送 (单位是秒)
soap->connect_timeout = 2;//连接(单位是秒)
转自:https://www.cnblogs.com/yishaochu/p/5078644.html
参考:https://www.cnblogs.com/liushui-sky/p/11889178.html