Network adapter communication at 100% packet loss - why am I getting internet availability status incorrectly?

I check the internet accessibility status using the Reachability class. But during testing, if I set 100% packet loss in developer settings, still I get the "ReachableViaWiFi" availability status. I am confused what is going on. Shouldn't it be "NotReachable" in this situation?

Here is my code snippet:

Reachability *networkReachability = [Reachability reachabilityForInternetConnection];
NetworkStatus networkStatus = [networkReachability currentReachabilityStatus];

if(networkStatus == NotReachable){
    NSLog(@"NotReachable");
}
else if(networkStatus == ReachableViaWiFi){
    NSLog(@"ReachableViaWiFi");
}
else if(networkStatus == ReachableViaWWAN){
    NSLog(@"ReachableViaWWAN");
}

      

I desperately need an answer. Is there any other way that gives me a FALSE status in this situation?

Thanks in advance!

+3


source to share


2 answers


The number of dropped packets does not affect availability. After all, it might just be short-lived (you took your phone into a shielded room, or just turned on a heavy electric motor). Reachability is your WiFi, 3G, or Ethernet on a Mac that's turned on. It's not about the quality of the connection.



+3


source


This worked for me:



-(BOOL)connected
{
    Reachability *r = [Reachability reachabilityWithHostName:@"www.google.com"];
    NetworkStatus internetStatus = [r currentReachabilityStatus];

    if ((internetStatus != ReachableViaWiFi) && (internetStatus != ReachableViaWWAN))
    {
        return NO;
    }
    else
    {
        return YES;
    }
}

      

0


source







All Articles