I’m using Apple’s SimplePing to ping a host on iPhone. I expect the following delegate methods to work.
(1) - (void)simplePing:(SimplePing *)pinger didSendPacket:(NSData *)packet;
(2) - (void)simplePing:(SimplePing *)pinger didReceivePingResponsePacket:(NSData *)packet;
(3) - (void)simplePing:(SimplePing *)pinger didReceiveUnexpectedPacket:(NSData *)packet;
(4) - (void)simplePing:(SimplePing *)pinger didFailToSendPacket:(NSData *)packet error:(NSError *)error;
The results are…
- Simulator: Methods (1) & (2 or 3 or 4) get called (correct)
- Device (Using WiFi): Methods (1) & (2 or 3 or 4) get called (correct)
- Device (Using 3G): Only methods (1) gets called. (incorrect, I expect (2 or 3 or 4) to also get calleA)
I tried some apps (Network Ping Lite, Free Ping, Ping Free) available in AppStore. Their result is similar to mine.
I wan’t to know if this is a bug in the SimplePing sample code by Apple or are there some other configurations I need to do?
Below is the code i’ve used
- (void)viewDidLoad {
[super viewDidLoad];
self.simplePing = [SimplePing simplePingWithHostName:@"www.google.com"];
[self.simplePing setDelegate:self];
[self.simplePing start];
}
- (void)simplePing:(SimplePing *)pinger didStartWithAddress:(NSData *)address {
[self.simplePing sendPingWithData:nil];
}
simply:
you can’t validate that a specific carrier supports or not supports a ping over the mobile network.