views:

164

answers:

1

Hi All,

Is there any way that we can programatically identify when the wifi of a user becomes available/unavailable?

My application requires exchanging messages between two different devices. It is working good in stable wifi setups. But if the wifi is unstable, I am having trouble in detecting if the other device is available or not.

I am not sure if this is expected, but my bonjour based NSNetService discoverer is not updating the available devices list automatically. This leaves me with a list of services that are not available for the exchange.

My line of thinking was to remove all the available services from the list and start a fresh search.

Please let me know if I am thinking in the right direction to solve the right problem.

Thanks in advance.

-Murali

+2  A: 

Perhaps the Reachability sample code provided by Apple will help you in this regard. Although there have been people who say it hasn't been updated in a while, in which case, here is an actively maintained fork.

It seems like you can register for notifications so you can get frequent information on the state of the network.

Jorge Israel Peña
This sounds very promising. I'll try to incorporate that and update how it goes.Thank you very much, Blaenk. I appreciate your help.
Nagamurali Manthena
You're welcome, glad I could help :)
Jorge Israel Peña
The Reachability sample code provide by Apple was last updated July 20, 2010.http://developer.apple.com/iphone/library/samplecode/Reachability/History/History.html#//apple_ref/doc/uid/DTS40007324-RevisionHistory-DontLinkElementID_1
Black Frog