简体   繁体   中英

Apple's SimplePing doesn't work over 3G

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...

  1. Simulator : Methods (1) & (2 or 3 or 4) get called (correct)
  2. Device (Using WiFi): Methods (1) & (2 or 3 or 4) get called (correct)
  3. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM