SCNetworkReachability giving nonsensical results in iOS Simulator
SCNetworkReachability giving nonsensical results in iOS Simulator
- Subject: SCNetworkReachability giving nonsensical results in iOS Simulator
- From: Jens Alfke <email@hidden>
- Date: Tue, 28 Apr 2015 14:49:26 -0700
SCNetworkReachability is returning weirdly wrong results in an iOS app I’m debugging. I’m running the app in the iOS Simulator (Xcode 6.3.1, iOS 8.3) and simulating offline mode by turning off WiFi on my Mac*. But the reachability values I’m getting don’t make any sense.
The code is adapted from code I’ve been using for years, so I pretty much trust it. It creates the ref with SCNetworkReachabilityCreateWithName (using a FQDN), then schedules it on a dispatch queue.
First I turn off WiFi and launch the app. My SCNetworkReachabilityCallBack function is called and logs:
Reachability change: (target=0x7ff53a093a30, info=0x7ff53a0939b0, flags=0007)
The flags indicate Transient connection + Reachable + Connection required. That's wrong — it implies something like PPP or a VPN is available that would make the host reachable.
Then when I turn WiFi back on, the callback logs:
Reachability change: (target=0x7ff53a093a30, info=0x7ff53a0939b0, flags=0000)
That of course means Unreachable, which is completely wrong.
I haven’t yet had a chance to try this with a real device.
—Jens
PS: Re. earlier discussions, I’m not using Reachability to determine whether or not to connect. It’s being used after there’s an error connecting to the host, with the intent of cutting short the retry interval and immediately retrying the connection when the host becomes reachable. But it’s not even working for that :(
* If the Simulator has menu items to do things like trigger iCloud sync and change the fake geo location, why doesn’t it have menu commands to simulate losing the network? There isn’t even an Airplane Mode toggle in the simulator’s Settings app. I’ll file a Radar.
_______________________________________________
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