views:

116

answers:

1

I'm currently implementing some logic for reading from TCP socket in the background mode.

CFReadStreamRead function is being used to fetch some data from socket and for now everything works fine.

But I'm wondering how iPhone OS 4.x treats blocking I/O operations in the background mode. For example: CFReadStreamRead function may block for hours while waiting for some incoming data.

Are there any official constraints like 10 minutes for the background tasks? Will my application be killed by iPhone OS for the case of long-running blocking I/O operation?

Please note - I'm not running the blocking I/O function in the background task. Code itself is situated inapplicationDidEnterBackground method of myUIApplicationDelegate.

Application itself is configured with "voip" parameter in Info.plst file + CFReadStream is configured according to the recommendations of Apple withkCFStreamNetworkServiceTypeVoIP parameter.

So basically this is a regular scenario of VoIP application in the background mode.

Thanks!

A: 

Replace it with sleep(86400), attach to it in the debugger, and see how long it is before you're killed. I don't think it'll be that long; you're supposed to respond to applicationDidEnterBackground: in a timely fashion. It almost certainly won't give you more time than beginBackgroundTaskWithExpirationHandler:.

Try checking [UIApplication backgroundTimeRemaining].

tc.