6
votes

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

Application 'MyAppName' exited abnormally with signal 13: Broken pipe

This is because my sockets are disconnected when my application goes to the background.

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

1
Is your app registered as a VOIP or streaming audio app? Those might be the only types which keep a socket alive in the background.hotpaw2
Yes..My info.plist have these properties "App plays audio,App provides Voice over IP services,App registers for location updates"...S.P.
Problem is when application is background and phone is in locked state..S.P.
Did you ever get this sorted out? I'm having the same issue and am curious about your solution.Kongress
@Kongress I used AsyncUdpSocket .Declared a CFReadStream and CFWriteStream variables globally and opened both streams.. If we opened a CFReadStream and CFWriteStream application will work as usual..S.P.

1 Answers

2
votes

This is not related to UDP. EPIPE only happens for "stream" file descriptors - Unix pipes and TCP sockets.

I'm guessing you have some sort of a control TCP connection which times out on the remote end when you go into background. You need to figure out how to keep it alive or re-connect when the app wakes up.

You can also handle (or ignore) EPIPE, see sigaction(2), and react to it accordingly on return from write(2).