Hi there!
I'm totally confused right now.
I have an iPhone Client connecting to a java server (port 80) using CFNetwork. When i do this in WLan, everything is great. Using EDGE, there are some strange things going on.
When i install the application it doesn't work at first. If i open safari on the iphone, write my ip in the address line and try to access my server this way my server gets data from the safari browser (can't do anythin with that data but that doesn't matter)
Now the strange thing: After i have done this my app can talk with my server. But only as long until i turn it off and on again. WTF is going on here?
Look at my connect method:
I'm totally confused right now.
I have an iPhone Client connecting to a java server (port 80) using CFNetwork. When i do this in WLan, everything is great. Using EDGE, there are some strange things going on.
When i install the application it doesn't work at first. If i open safari on the iphone, write my ip in the address line and try to access my server this way my server gets data from the safari browser (can't do anythin with that data but that doesn't matter)
Now the strange thing: After i have done this my app can talk with my server. But only as long until i turn it off and on again. WTF is going on here?
Look at my connect method:
HTML:
-(BOOL)connect{
NSLog(@"%d",port);
NSLog(srvaddr);
struct sockaddr_in ipAddress;
ipAddress.sin_family = AF_INET;
ipAddress.sin_port = htons(port);
ipAddress.sin_addr.s_addr = inet_addr([srvaddr UTF8String]);
data = CFDataCreate(NULL, (UInt8 *)&ipAddress, sizeof(struct sockaddr_in));
CFSocketSignature sig = {PF_INET, SOCK_STREAM, IPPROTO_TCP, data};
CFOptionFlags registeredCallbacks = kCFSocketReadCallBack|kCFSocketDataCallBack|kCFSocketConnectCallBack|kCFSocketWriteCallBack;
CFSocketContext socketCtxt = {0, self, NULL, NULL, NULL};
[COLOR="Red"]// usually i get a socket = NULL here if the error occurs[/COLOR]
socket = CFSocketCreateConnectedToSocketSignature(NULL, &sig, registeredCallbacks , socketCallback, &socketCtxt, 0);
if(socket == NULL){
return NO;
}
else{
CFRunLoopSourceRef source = CFSocketCreateRunLoopSource(NULL, socket, 0);
CFRunLoopRef loop = CFRunLoopGetCurrent();
CFRunLoopAddSource(loop, source, kCFRunLoopDefaultMode);
return YES;
}
}