I tested different frameworks, e.g.
- https://github.com/tonymillion/Reachability
- https://github.com/VerticodeLabs/VCLReachability
- https://github.com/kstenerud/KSReachability
and I would like to know if a host is reachable. On my iPhone, I set my iMac as proxy (Charles) and block or don't block the connections, but the reachability is always YES. Only if I set a non-existing host, it returns NO. But if the host exists but I block the connection to it, I always get isReachable
. Isn't there a way to check if the host is really reachable?
If I try with KSReachability, I'm doing the following:
self.reachability = [KSReachability reachabilityToHost:@"www.stackoverflow.com"];
self.reachability.notificationName = kDefaultNetworkReachabilityChangedNotification;
self.reachability.onReachabilityChanged = ^(KSReachability *reachability) {
NSLog(@"isReachable: %i", reachability.reachable);
};
I always get isReachable: 1
there with the following configuration:
- connected to Wifi
- configured my iMac as HTTP-Proxy
- blocking www.stackoverflow.com in my Charles Proxy
When I try to reach www.stackoverflow.com in Safari, the page can't be opened (as expected). I would expect the reachability to be false (isReachable: 0
) in this case.
EDIT So the most important question for me is - how to achieve the behavior I'm expecting? I.e. that the app continuously checks if the given host is really reachable?