tl;dr: Using SCNetworkReachabilityCreateWithName, how do I tell the difference between “the device is offline” and “you are online but the hostname couldn’t be found”?
I’ve been using SCNetworkReachabilityCreateWithName() for a while but just ran into an issue with it. If it’s given a hostname that fails to resolve — say “fdsf.fdsd” or “
moseyard.com” — it reports that the host is unreachable by returning an empty set of flags (0).
Which is true as far as it goes, but I can’t tell it apart from a genuinely-offline state. If the device is offline I want my networking code to wait idly until it’s notified that the host is reachable; but if the user’s entered an incorrect hostname I should return an error right away. Currently my code can’t tell the difference, so if the user makes a typo in a URL’s hostname she’ll probably never get notified of the mistake, just wait forever while nothing happens.
(I’m aware that there are cases where a hostname-not-found error is genuinely transient and it might be appropriate for the app to wait; e.g. if it’s an intranet host that’s only visible when logged into a VPN. But that’s a less common situation.)
It would be nice if SCNetworkReachability could indicate this state somehow, like with a flag indicating “DNS was reachable but your hostname couldn’t be found”, which I can choose to treat as an error. I’ve looked through the header but can’t find anything like this; am I missing something or should I file a Radar?