I have a similar need, but Reachability doesn't seem to do it.
My app is intended for an iPod Touch connecting via WiFi to an adhoc network created by a WiSnap (
Wi-Fi RS-232 serial adapter iPhone Android BlackBerry Windows Symbian) that is essentially a WiFi-to-RS232 adapter. The WiSnap [hosts?] the adhoc network on 169.254.1.1.
I need to be able to tell (1) if the WiSnap is powered up and the adhoc network available, (2) if I can actually reach 169.254.1.1, and (3) if my socket connection is working.
Well, I modified the reachability sample program to go to 169.254.1.1 instead of
Apple. I'll describe a scenario where, at some prior time, the iPod was connected to the adhoc WiFi network. I turn both iPod and WiSnap power off. I turn iPod back on. I run Reachability. It says that Rmote Host 169.254.1.1 is "Reachable WiFi". It says the same for TCP/IP routing and local WiFi. This is NOT TRUE. The power is still OFF to the WiSnap. There is NO adhoc network in existence.
When I go to Settings on the iPod and look at WiFi, it still lists the WiSnap on the the main Settings page ("WiSnap-3727" is the adhoc network name). If I touch and go to the Wi-Fi Networks view, there's still a check mark net to WiSnap-3727, but the signal strength icon is almost all grayed out.
So, I believe the Settings program knows there's not actually a connection at the moment. But Reachability doesn't.
To further test, I can change WiFi connections to my office LAN, which is obviously different from the WiSnap. When I do this and subsequently run Reachability, it can still find remote host 169.254.1.1 (this must be some OTHER host on my LAN, not the WiSnap. I'm not worrying about this.) It says TCP/IP routing works. However, for Local WiFi, it says "Access Not Available". This is *indeed* what I *expect*.
Now I change WiFi connections back to the WiSnap. Well, I can't do that without turning the WiSnap on. I do so. I connect with Settings app. I immediately turn WiSnap power back OFF before leaving Settings app. I exist Settings and run Reachability. It thinks I can reach WiSnap. So, it's not going 'far enough' determining reachbility.
IN ADDITION TO ALL THIS, what I really need is for my app to assist the user in switching between TWO different adhoc networks. One is the adhoc network between the iPod and the WiSnap. Another is a hypothetical adhoc between the iPod and a lone Laptop. For test purposes, I can use my office WiFi LAN in lieu of the lone Laptop. Either way, I want my app to be able to SWAP connections between the two networks.