tags:

views:

491

answers:

1

My iPhone application establishes a TCP connection through wifi to a remote server. However, if there is no user activity for a certain time, the device closes wifi and drops the connection. Is it possible to prevent it? I need the connection to be persistent while the application is running. Setting setIdleTimerDisabled:YES doesn't help - it prevents the screen to go off, but still the wifi is closed.

Do you know if this is possible and how to achieve it?

+5  A: 

Check out this URL: http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/ApplicationEnvironment/ApplicationEnvironment.html#//apple_ref/doc/uid/TP40007072-CH7-SW59

Table 1-3 Important keys in the Info.plist file

UIRequiresPersistentWiFi:

A Boolean value that notifies the system that the application uses the Wi-Fi network for communication. Applications that use Wi-Fi for any period of time must set this key to true; otherwise, after 30 minutes, the device shuts down Wi-Fi connections to save power. Setting this flag also lets the system know that it should display the network selection dialog when Wi-Fi is available but not currently being used. The default value is false.

Dutchie432
Note that WiFi has a significant effect on battery life. It might be better to accept the dropped connection and reconnect on failure. That would make your application more robust in general.
Roger Nolan