How to check local Wi-Fi connection

I am writing an application that connects to a static IP address on 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 to use the class Rechability

, but it returns FALSE

while the device is definitely connected (when I don't 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 this work out?

Thomas

+2


a source to share


2 answers


I was under the impression that you were not following the usage guidelines as described in the ReadMe and sample code. You seem to be checking the status synchronously and immediately, which doesn't work. Take a look at the applicationDidFinishLaunching method in ReachabilityAppDelegate.m which shows how to wait for a response to enter (via reachabilityChanged) before you check the status. Also, you might need to call startNotifer to get this to work.



+1


a source


The problem I see with this: "http: //" is not a hostname;)

You should only check your ip without the http part!



(I know this is old, but there was no answer and you can find it through a search)

0


a source







All Articles