iOS "NSLocalizedDescription=Broken pipe" Error For UDP

1.4k Views Asked by At

I encounter this error(UDP didNotSendDataWithTag: 213 Error: Error Domain=NSPOSIXErrorDomain Code=32 "Broken pipe" UserInfo=0x165acab0 {NSLocalizedDescription=Broken pipe}) after the app comes back after screen lock.

Note: Before screen lock, a udp send loop is running which sends udp data every 10 secs.

I tried reopening the socket again but that didn't work. It seems that the socket was not really closed at all. Its just that the data cant be sent. Does anyone know the solution to this problem? Many thanks!

1

There are 1 best solutions below

0
On BEST ANSWER

I was able to solve the problem by closing the udp socket when the app is went to background

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    //close UDP Socket here
}

and then turning it back on when it comes back to foreground.

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    //open UDP Socket again and continue tasks
}

Hope this helps other developers when they encounter this problem. :)