1

我目前正在实现一些在后台模式下从 TCP 套接字读取的逻辑。

CFReadStreamRead函数用于从套接字获取一些数据,现在一切正常。

但我想知道 iPhone OS 4.x 如何在后台模式下处理阻塞 I/O 操作。例如:CFReadStreamRead函数在等待一些传入数据时可能会阻塞数小时。

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!

4

1 回答 1

0

将其替换为sleep(86400),在调试器中附加到它,然后查看您被杀死之前的时间。我认为不会那么久;你应该applicationDidEnterBackground:及时回复。它几乎肯定不会给你更多的时间beginBackgroundTaskWithExpirationHandler:

尝试检查[UIApplication backgroundTimeRemaining]

于 2010-08-11T18:51:17.650 回答