Reachability sample app

  • It tests three things: remote host, tcp/ip routing, and local wifi.

    Running in the simulator, if I turn off WiFi, only the remote host status changes. If I quit and re-launch it with WiFi disabled, I get the same result.

    If I then re-enable WiFi, only "local WiFi" shows as unavailable, until I re-launch.

    In no case does it seem to reliably update while running.

    Is this a simulator issue? Or is SCNetworkReachability not reliable?

    Thanks!

    --
    Rick
  • On May 31, 2013, at 1:14 PM, Rick Mann <rmann...> wrote:

    > Running in the simulator, if I turn off WiFi, only the remote host status changes. If I quit and re-launch it with WiFi disabled, I get the same result.
    > If I then re-enable WiFi, only "local WiFi" shows as unavailable, until I re-launch.
    > In no case does it seem to reliably update while running.
    > Is this a simulator issue? Or is SCNetworkReachability not reliable?

    Pretty sure it’s a simulator issue. I’ve used SCNetworkReachability a lot and it’s reliable at what it does.

    I suspect what’s happening is that the simulator runs behind some kind of imaginary router that in turn connects to your real network interface. If that’s true, then if you turn off WiFi on your Mac, from the simulator’s point of view that would be an upstream network change that it won’t see directly; the LAN it thinks it’s on is the one provided by that imaginary router.

    (It would be as though you set up Internet Sharing on your Mac to share an Ethernet connection, and then connected your iPhone to that WiFi network: if you do that and then unplug your Mac’s Ethernet, the iPhone won’t detect the change because its own LAN (WiFi) is still up. All it can tell is that packets it sends to the outside world never get responses, and that’s not the kind of thing that SCNetworkReachability can or will tell it about.)

    I don’t know this for sure, though. (And I think the people who would know are on the macnetworkprog list, not necessarily cocoa-dev.) But try your app on a real device and you should get better results.

    —Jens
  • Thanks, Jens, that makes a lot of sense, and puts me at ease that this will do what I need.

    On May 31, 2013, at 13:56 , Jens Alfke <jens...> wrote:

    >
    > On May 31, 2013, at 1:14 PM, Rick Mann <rmann...> wrote:
    >
    >> Running in the simulator, if I turn off WiFi, only the remote host status changes. If I quit and re-launch it with WiFi disabled, I get the same result.
    >> If I then re-enable WiFi, only "local WiFi" shows as unavailable, until I re-launch.
    >> In no case does it seem to reliably update while running.
    >> Is this a simulator issue? Or is SCNetworkReachability not reliable?
    >
    > Pretty sure it’s a simulator issue. I’ve used SCNetworkReachability a lot and it’s reliable at what it does.
    >
    > I suspect what’s happening is that the simulator runs behind some kind of imaginary router that in turn connects to your real network interface. If that’s true, then if you turn off WiFi on your Mac, from the simulator’s point of view that would be an upstream network change that it won’t see directly; the LAN it thinks it’s on is the one provided by that imaginary router.
    >
    > (It would be as though you set up Internet Sharing on your Mac to share an Ethernet connection, and then connected your iPhone to that WiFi network: if you do that and then unplug your Mac’s Ethernet, the iPhone won’t detect the change because its own LAN (WiFi) is still up. All it can tell is that packets it sends to the outside world never get responses, and that’s not the kind of thing that SCNetworkReachability can or will tell it about.)
    >
    > I don’t know this for sure, though. (And I think the people who would know are on the macnetworkprog list, not necessarily cocoa-dev.) But try your app on a real device and you should get better results.
    >
    > —Jens

    --
    Rick
previous month may 2013 next month
MTWTFSS
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
Go to today