views:

148

answers:

1

hi all,

I'm writing an app which connects to a static ip adress in a local network. How can I check if I have a local network connection? I want to connect to http://192.168.2.5 and i tried using the Rechability class but it returns FALSE, while the device is definately connected ( when i don't do the check, the app works fine so there is a connection ):

Reachability *r = [Reachability reachabilityWithHostName:@"http://192.168.2.5"]; NetworkStatus internetStatus = [r currentReachabilityStatus];

How should work this out?

Thomas

A: 

I have the impression you have not followed the usage rules as explained in the ReadMe and the sample code. You seem to check for the status synchronously and immediately, which is not working. Look at the applicationDidFinishLaunching method in ReachabilityAppDelegate.m which shows how to wait for the answer to come in (via reachabilityChanged) before you check the status. Also, you may need to call startNotifer to get this working.

Thomas Tempelmann