• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: SCNetworkReachability and unknown hostnames
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SCNetworkReachability and unknown hostnames


  • Subject: Re: SCNetworkReachability and unknown hostnames
  • From: Matt DeFoor <email@hidden>
  • Date: Sat, 17 Aug 2013 17:54:36 -0400

AFAIK, you're not missing anything. I looked for something like this years ago and found nothing reliable short of trying to open a socket connection to the desired address. I'd be interested if an alternative existed as well.

-Mattd


On Sat, Aug 17, 2013 at 3:30 PM, Jens Alfke <email@hidden> wrote:
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?

—Jens

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >SCNetworkReachability and unknown hostnames (From: Jens Alfke <email@hidden>)

  • Prev by Date: SCNetworkReachability and unknown hostnames
  • Next by Date: Re: SCNetworkReachability and unknown hostnames
  • Previous by thread: SCNetworkReachability and unknown hostnames
  • Next by thread: Re: SCNetworkReachability and unknown hostnames
  • Index(es):
    • Date
    • Thread