How can I run UDP sockets in the background in an iPhone application?

My iPhone application uses AsyncUdpSocket to handle a UDP socket. However, when my application goes into the background in iOS 4.0 and returns to the foreground, I get the following error:

The application "MyAppName" came out abnormally with signal 13: Broken pipe

This is because my sockets are disabled when my application goes into the background.

How can I avoid this and run UDP sockets in the background?

+6
objective-c iphone udp sockets
source share
1 answer

This is not related to UDP. EPIPE occurs only for stream file descriptors — Unix pipes and TCP sockets.

I assume that you have some kind of controlled TCP connection that comes at the remote end when you go into the background. You need to figure out how to save it or reconnect when the application wakes up.

You can also handle (or ignore) EPIPE , see sigaction(2) and respond to it accordingly when returning from write(2) .

+2
source share

All Articles