checking network reachability at a particular instant
When the user presses a button, I need to know whether the device is
connected to the internet at that very instant--not whether he was
connected 3 seconds ago. The reachability (tonymillion) notifier takes
about that long to update.
I thought that I would be able to check for actual access using the
following methods:
if (!([[Reachability reachabilityWithHostname:@"www.google.com"]
currentReachabilityStatus] == NotReachable)) NSLog(@"reachable");
if ([[Reachability reachabilityWithHostname:@"www.google.com"]
currentReachabilityStatus] == NotReachable) NSLog(@"not reachable");
But results indicated that in fact currentReachabilityStatus does not
perform an actual network check; it only checks the same flag that is
updated with ~3 seconds' delay.
What's an efficient way of actually checking for network access on the spot?
No comments:
Post a Comment