0

Anyone have an idea on how I could check for a wifi connection where I don't necessarily need to connect to the internet? I've implemented wifi multiplayer in a game I'm working on, so I want to make sure and let the user know if there's no connection when they are trying to use that mode. The Reachability sample code seems to only work for situations where you have a host you are trying to route to. Since I have no knowledge of how other people's wifi will be set up, I need to be able to check for wifi without trying to route to a specific place.

Edit: Nevermind, I've got it. Just took a little more digging in the Reachability code.

4

2 回答 2

0

You can check that you reach the access point (which will almost always be the iPhone's gateway, Internet or not). 802.11b/g/n with a route to the Internet and without a route to the Internet will appear exactly the same to the phone -- or any device, for that matter.

I could foresee asking the phone for its gateway and attempting to talk to it (ping, maybe?) but I'm unfamiliar with the Reachability approach. If indeed you have figured it out, I'd love to see an answer.

于 2009-12-06T22:28:05.640 回答
0

There is a method in the reachability class that returns an instance for wifi. I think it was called reachabilityForLocalWiFi.

于 2011-06-10T17:36:53.523 回答