How to check internet connection reachability in wireless local area network?

Featured Image

You think you will find answer on this question here? I am sorry to disappoint but you are not going to find right answer here. Here you will find ways how you can not check internet connection reachability in some wireless local area network. 🙂

I know you will now say there is “Reachability” named sample app at developer connect library to download, but it ain’t what I am looking for. What I am looking for is feature that will tell me do I have internet connection while I have network connection, to be more accurate, do I have internet connection while I am connected to some wireless local area network? I know, some of you will now say: “Well you can make NSURLConnection and wait for didFailWithError or connectionDidFinishLoading delegate methods”. Yeah, but this again ain’t what I am looking for.

What I was really looking for is something like pinging some host. Again, you will now say: “Well, you might don’t know but Reachability sample app has way to test reachability of given host.” Yeah, but this again ain’t what I am looking for.

I just hope that Apple’s developers will soon add some really easy way to do something like this. Please don’t hesitate to leave comments, and please tell me I am wrong on this one and easy way really exist. Please that I am blind as mole and I can’t see! 🙂 Thanks!


  1. Hi Ivan,

    I am stuck with the same problem.
    Did you figure it out?

    I want to check the real internet connection not just to router.

    Hope to hear from U.


  2. thank you Chris

    i used your code on the main.m file ! but igot this error :

    FATAL ERROR : method definition not in @implementation context

    i imported : #import

    but still got FATAL ERROR
    what can i do ?

  3. Indeed reachability is the answer – it checks if the host “” is available – therefore checking you’re internet connection. here is simple code I striped out of reachability for my app:

    BOOL connected;
    const char *host = “”;
    SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, host);
    SCNetworkReachabilityFlags flags;
    connected = SCNetworkReachabilityGetFlags(reachability, &flags);
    BOOL isConnected = connected && (flags & kSCNetworkFlagsReachable) && !(flags & kSCNetworkFlagsConnectionRequired);
    return isConnected;

    You will need to import these at the top of your .m file


    And make sure you have added the SystemConfiguration.framework to your project (add existing framework)

    And you can use this to check it works:

    if([self connectedToWeb]) NSLog(@”Connected”);
    else NSLog(@”Not Connected”);

    1. Thanks Chris, but as I have already mention, I have seen Apple’s Reachability sample app and that code snippet. To see my main issue try to do this: 1. Connect iPhone on your router via wifi connection; 2. Unplug internet connection cable from your router , but don’t shout it down. Your iPhone must still be connected to router’s wireless local area network. 3. Final, try to use app with this code. If you didn’t split your processes on another thread your app will freeze.


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.