Quote:
Originally Posted by rhawkey
That's the host part of the reachability class. You can check not only whether the device is connected to a network but also whether a host is reachable. So if you check whatever your end target is that you're trying to connect to then you know the router is online. The remoteHostStatus method is what you're looking for.
By the way be careful where you put these tests. I've had some apps crash from timeouts on launch by having them in the startup code for my app. In the end I moved all of my reachability testing to a thread which sets a flag that I later poll from the main thread. Not only the network device connection test but also the host test can take a really long time and trigger the iPhone OS watchdog to kill your app if it's on the main thread.
|
Hi and thanks a lot for your awnser. I can`t seem to find the remoteHostStatus that you are talking about.
I am using the method
Code:
+ (Reachability*) reachabilityWithHostName: (NSString*) hostName;
Aint that the right one?
Right now i am using the following code to test several differents scenarios.
Code:
hostReach = [[Reachability reachabilityWithHostName: @"www.google.com"] retain];
[hostReach startNotifer];
[self updateInterfaceWithReachability: hostReach];
internetReach = [[Reachability reachabilityForInternetConnection] retain];
[internetReach startNotifer];
[self updateInterfaceWithReachability: internetReach];
wifiReach = [[Reachability reachabilityForLocalWiFi] retain];
[wifiReach startNotifer];
[self updateInterfaceWithReachability: wifiReach];
I have 3 different objects of the reachability class where one is initialised with the host example, another with internetReach and the last one with localwifi. This code is taken right from Apples example class that follows with the Reachability code from their homepage. When i run apples reachability code all seems to be running fine. With that i meen that when i am connected to to a wifi that can reach out on the net, the application (reachability) says that all three object can reach the internet ture wifi, while if I connect to a wifi which is not connected to the internet i get not able to connect from two of the reachability objects (reachabilityForInternetConnection and reachabilityWithHostName) while reachabilityForLocalWiFi still give me back wifi aviliablewhich are correct.
Thats why i can`t see why it fails now when i just move the code from apples example into my project. I thought i was using the code correctly, but in my application i get the go ahead on all three object when i am connected to a wifi which aint connected to the internet. Only the local wifi should give me that. Any help on this subject would be greatly apprishiated

(You was talking about the last versions of apples reachability code right?
And thanks a lot for the heads up about the watchdog. I have read something about this in other threads about the subject asweel, but right now i actually have it in the startup of the program

So guess i have to try fix that.
Is there any chance that you might post some of your code or show me a good example of how you run in it in another thread? And how you get the code to properly check if it can reach the host or not
Thanks for your help so far