My App uses the opensource ios-ntp framework (https://github.com/jbenet/ios-ntp)
So far, it works fine my Apps uses the commands available to calculate the time difference between the system time and network time and applies this to a localnotification.

However, the app crashes if the connection gets lost, I think this is because the NTP socket connection does not get closed after time syncing?

This is what happens:

1) Turn the App on, let it sync with the timeserver then put the App in background mode

2) Turn Airplane mode on, or just wait a while until the connection changes from WiFi to 3G e.d.

How should I prevent this? Is there a way to close the connection after syncing with the NTP server since I can't find one.

AppDelegate

- (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];
}

Signal 13 is this -> 13 SIGPIPE terminate process write on a pipe with no reader. It probably means you are trying to write into an invalid socket. Show your code when the app comes into the foreground.
–
borrrdenJun 25 '13 at 7:01

That doesn't help much. What are you doing inside checkForReachability. Also, what are you doing when the app goes into the background. Are you closing the socket?
–
borrrdenJun 25 '13 at 7:28

@borrrden No I'm not since I don't know how to, it seems that there is some automatic code in the framework because it reports NetworkClock application -> Background - [self checkForReachability]; just checks if there is an internet connection, don't think that's the issue though.
–
TimothyJun 25 '13 at 9:12

Any updates on this question. am also having this same issue.
–
Irshad MohamedJul 16 '14 at 10:07