变更记录

序号 录入时间 录入人 备注
1 2016-06-12 Alfred Jiang -

方案名称

网络 - 使用 SimplePingHelper 在 iPhone / iPad 上 ping 指定服务器

关键字

网络 \ ping \ 检测服务器连接

需求场景

  1. 测试 ping 连接

参考链接

  1. Chris Hulbert - How to ping a server in Objective-C / iPhone(推荐)
  2. GitHub - chrishulbert/SimplePingHelper
  3. Zubin’s Blog - 苹果示例源码阅读:SimplePing

详细内容

1. 将 SimplePingHelper 相关代码引入工程
2. 使用方法如下
1
2
3
4
5
6
7
8
9
10
11
12
- (void)tapPing {
[SimplePingHelper ping:@"www.google.com"
target:self sel:@selector(pingResult:)];
}

- (void)pingResult:(NSNumber*)success {
if (success.boolValue) {
[self log:@"SUCCESS"];
} else {
[self log:@"FAILURE"];
}
}

效果图

(无)

备注

(无)