Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 05-04-2010, 05:41 AM   #35 (permalink)
Peewee
Registered Member
 
Join Date: May 2010
Posts: 2
Peewee is on a distinguished road
Default

Quote:
Originally Posted by rhawkey View Post
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

Last edited by Peewee; 05-04-2010 at 06:02 AM. Reason: More info
Peewee is offline   Reply With Quote
 

» Advertisements
» Online Users: 388
22 members and 366 guests
Absentia, alexP, blackcat_tq, Bobarino, Duncan C, eski, Farfalo, flamingliquid, Garros1990, hacker073, ilmman, jbro, mongmo, MysticLine, n00b, Newbie123, NSString, PandaUser, pinky, Sami Gh, SillyHoney, SuperDietGenius
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,560
Threads: 94,079
Posts: 402,744
Top Poster: BrianSlick (7,990)
Welcome to our newest member, mongmo
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:48 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.