• 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: Reachability redux: what about the user experience?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reachability redux: what about the user experience?


  • Subject: Re: Reachability redux: what about the user experience?
  • From: Allan Nathanson <email@hidden>
  • Date: Mon, 27 Apr 2009 13:34:55 -0400

kSCNetworkFlagsConnectionRequired != kSCNetworkFlagsConnectionAutomatic.

In this case, it is "possible" for your network traffic to reach the target host but you must first establish a connection. This could via the Network pref pane or menu extras and would likely involved dialing a modem, starting a WWAN (3G/cell) network, establishing a link via Bluetooth to a network, etc.

In general, your code should be looking for :

Boolean
tryToConnect(SCNetworkReachabilityFlags flags)
{
  if (((flags & kSCNetworkFlagsReachable) != 0) {
      ((flags & kSCNetworkFlagsConnectionRequired) == 0)) {
    // if reachable and no connection required
    return TRUE;
  }

  // if not reachable OR a connection is required
  return FALSE;
}


- Allan



On Apr 27, 2009, at 11:57 AM, Rich Siegel wrote:

Good morning,

On 9/9/07 at 5:51 PM, email@hidden (Rich Siegel) wrote:

I've written some code which schedules a SCNetworkReachabilityRef and
inspects the reachability flags before attempting a recurring
automatic network connection (think "software update" or "email
check"). I've been fairly strict in interpreting the reachability
flags: if (0 == (flags & kSCNetworkFlagsReachable)) then I don't
attempt to connect.

Note the date on that. :-) Since then, I've had pretty good luck in sorting out SCNetworkReachability and making good use of it. However, there remain some cases in which things are a little fuzzy.


My latest issue is a case reported by a beta site: he has a single Ethernet interface configured (he says :-)) and when his machine is unhooked from the wire, my scheduled network activities are attempted, even though they shouldn't be. I have logging code in place, and when he unhooks the wire, a log entry gets created:

   2009-04-26 15.26.21 Redacted[176] Reachability transition for
   host redacted.example.com: flags 0x7 (reachable,  transient)

When he plugs the wire back in:

   2009-04-26 15.34.00 Redacted[176] Reachability transition for
   host redacted.example.com: flags 0x2 (reachable)

Now, clearly there's a bug in my logging code, because 0x7 is really (kSCNetworkFlagsTransientConnection | kSCNetworkFlagsReachable | kSCNetworkFlagsConnectionRequired). But since kSCNetworkFlagsReachable is set, I go ahead and try the connection anyway, and of course it fails.

The documentation doesn't provide much guidance on how network reachability and user experience should relate (which I guess makes sense, since it's probably application-dependent). But for me the big question is: how do reachability and user experience relate? Today, if the host is reachable, I try to connect. But clearly, reachability as reported by the API isn't the only determinant - should I only try to connect if kSCNetworkFlagsConnectionRequired is not set?

Thanks for any advice,

R.
--
Rich Siegel Bare Bones Software, Inc.
<email@hidden> <http:// www.barebones.com/>


Someday I'll look back on all this and laugh... until they sedate me.

_______________________________________________
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
  • Follow-Ups:
    • Re: Reachability redux: what about the user experience?
      • From: Rich Siegel <email@hidden>
References: 
 >Reachability redux: what about the user experience? (From: Rich Siegel <email@hidden>)

  • Prev by Date: Reachability redux: what about the user experience?
  • Next by Date: Re: Reachability redux: what about the user experience?
  • Previous by thread: Reachability redux: what about the user experience?
  • Next by thread: Re: Reachability redux: what about the user experience?
  • Index(es):
    • Date
    • Thread