views:

262

answers:

1

Hi there,

I have an iPhone VOIP app that copes with multi-multi transmit and receive (ie teleconferencing) set up using BSD sockets. I would like it to be able to respond to incoming requests when it is in the background but from what I can understand of the iOS 4 docs I can only do this on an NSStream object (or CFRead/WriteStream) by setting the property to NSStreamNetworkServiceTypeVoIP. This is a bit of a problem as my system is a UDP BSD sockets based application. Everything is received and sent on a single UDP socket.

Am I going to need to re-write my audio transmit/receive core to handle NSStreams or is there a way I can get iOS 4 to handle my BSD socket in a similar way to an NSStream? I assume this may be a problem as an NSStream is event based.

Would it be possible to detect when the application goes into the background and build a temporary NSStream object that will pass the data on to through the relevant handling and then continue as normal? Is it even possible to create a UDP NSStream?

Any ideas?

+2  A: 

You can create a socket from a file descriptor with CFSocketCreateWithNative(), and then create a pair of streams with CFStreamCreatePairWithSocket(). It might let you use them on a UDP socket. Provided the streams don't read data unless you ask, you might be able to get away with using the FD directly.

Good luck with that though!

tc.
Ok It does seem to work. Turns out I can't automatically start an audio recording stream in the background but it DOES give me control when data arrives on the UDP port (Which is well worth knowing!)
Goz