1

我的应用程序使用开源ios-ntp框架 ( https://github.com/jbenet/ios-ntp ) 到目前为止,它工作正常我的应用程序使用可用的命令来计算系统时间和网络时间之间的时间差并将其应用于本地通知。

但是,如果连接丢失,应用程序会崩溃,我认为这是因为时间同步后 NTP 套接字连接没有关闭?

这就是发生的事情:

1)打开应用程序,让它与时间服务器同步,然后将应用程序置于后台模式

2)打开飞行模式,或者等待一段时间,直到连接从 WiFi 变为 3G ed

3)重新打开应用程序,它会崩溃并返回以下内容:

Jun 25 09:00:11 iPhone App[460] <Warning>:             NetworkClock|*** application -> Foreground
Jun 25 09:00:11 iPhone com.apple.launchd[1] (UIKitApplication:nl.app[0x8f48][460]) <Warning>: (UIKitApplication:nl.app[0x8f48]) Exited abnormally: Broken pipe: 13
Jun 25 09:00:11 iPhone backboardd[28] <Warning>: Application 'UIKitApplication:nl.app[0x8f48]' exited abnormally with signal 13: Broken pipe: 13

我应该如何防止这种情况?有没有办法在与 NTP 服务器同步后关闭连接,因为我找不到。

应用委托

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    [self checkForReachability];
}
4

0 回答 0