通过 socket.h 调用 connect() 时,使用 GSoap 返回 EHOSTUNREACH
我目前正在构建一个基于 Gsoap 工具包的 iPhone 应用程序以连接到一个网络服务。一切正常,除了当我在设备上断开并重新连接 3g 后尝试连接到我的服务时,我得到:
SOAP 1.1 fault: SOAP-ENV:Client [no subcode]
"Connection refused"
Detail: connect failed in tcp_connect()
通过调试器显示错误来自 socket 的
。 我不太明白,当我启动另一个应用程序(如 safari)时,设备会连接到互联网。加载网页后,我的应用程序的连接工作正常。connect()
方法.h
这是我正在使用的代码:
//GSoap initialization
struct soap soap;
soap_init(&soap);
soap.connect_timeout = 0;
soap.send_timeout = 0;
soap.recv_timeout = 0;
// objects request & response
// struct types can be foundin soapStub.h
struct _ns1__GetAuthentification requete;
struct _ns1__GetAuthentificationResponse reponse;
// init request
requete.ConnectPass = (char *) [connectPass UTF8String];
requete.Login = (char *) [login UTF8String];
requete.Password = (char *) [password UTF8String];
requete.soap = &soap;
// request callback. returns SOAP_OK if something has been returned
if(soap_call___ns1__GetAuthentification(&soap,NULL,NULL, &requete,&reponse) == SOAP_OK){
//then we build the result
NSLog(@"Yay!");
soap_end(&soap); // remove deserialized data and clean up
soap_done(&soap); // detach the gSOAP environment
return authResult;
}
else {
//NSLog(@"Soap Error : GetAuthentification");
// We try to see if there's any problem. @catch statements are here just to keep note of the concerned
// exceptions for each request. No utility for the code.
@try {
[self processFault:&soap];
}
@catch (MMWrongId * e) {
@throw e;
}
@catch (MMConnectionFailed * e) {
@throw e;
}
@catch (MMGetAuthentificationFault * e) {
@throw e;
}
return nil;
}
我是否缺少任何特定的标志/选项?
I'm currently building an iPhone app based on Gsoap toolkit to connect to a webservice. Everything works fine except when I try to connect to my service after disconnecting and reconnecting 3g on the device, I get :
SOAP 1.1 fault: SOAP-ENV:Client [no subcode]
"Connection refused"
Detail: connect failed in tcp_connect()
Working through the debugger shows that the error comes from connect()
method of socket.h
.
I don't really understand, when I launch another app like safari, the device is connected to the Internet. And after loading a web page, my app's connection works fine.
Here is the code I'm using :
//GSoap initialization
struct soap soap;
soap_init(&soap);
soap.connect_timeout = 0;
soap.send_timeout = 0;
soap.recv_timeout = 0;
// objects request & response
// struct types can be foundin soapStub.h
struct _ns1__GetAuthentification requete;
struct _ns1__GetAuthentificationResponse reponse;
// init request
requete.ConnectPass = (char *) [connectPass UTF8String];
requete.Login = (char *) [login UTF8String];
requete.Password = (char *) [password UTF8String];
requete.soap = &soap;
// request callback. returns SOAP_OK if something has been returned
if(soap_call___ns1__GetAuthentification(&soap,NULL,NULL, &requete,&reponse) == SOAP_OK){
//then we build the result
NSLog(@"Yay!");
soap_end(&soap); // remove deserialized data and clean up
soap_done(&soap); // detach the gSOAP environment
return authResult;
}
else {
//NSLog(@"Soap Error : GetAuthentification");
// We try to see if there's any problem. @catch statements are here just to keep note of the concerned
// exceptions for each request. No utility for the code.
@try {
[self processFault:&soap];
}
@catch (MMWrongId * e) {
@throw e;
}
@catch (MMConnectionFailed * e) {
@throw e;
}
@catch (MMGetAuthentificationFault * e) {
@throw e;
}
return nil;
}
Am I missing any particular flag/option?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于那些遇到同样问题的人,我找到了解决方案。 Michael Lasmanis 对此提供了巨大的帮助。这是他的回答:
For those who encounter the same issue, I got a solution. Michael Lasmanis has been a huge help for this one. Here is his answer :