Is there a way to make sure a specific HTTP request on an iPhone goes over the LTE network, even when the iPhone is connected to wifi?
That depends on the API you’re using. If you’re using a high-level API, like
NSURLSession
, there’s no way to force the request to run over a specific interface [1]. If you’re using a low-level API, specifically BSD Sockets, you can do this by binding the socket’s source address. Alas, there’s some serious gotchas with this approach, as I discussed in the
thread you referenced.
If you'd like to see better support for this added to
NSURLSession
in the future, I encourage you to file an
enhancement request describing your requirements. While we may have seen similar requests before, a fresh bug report will allow you to express your needs in your own terms, and allow the CFNetwork team to gauge the level of demand.
Please post your bug number, just for the record.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"
[1] There two edge cases here:
You can stop it running over WWAN via the
allowsCellularAccess
property, but that technically doesn’t force it to run over a specific interface: it could run over Wi-Fi or Ethernet (yes, even on iOS).Hotspot helpers can force a request to run over the specific interface associated with the hotspot (see
-bindToHotspotHelperCommand:
in <NetworkExtension/NEHotspotHelper.h>
) but that’s not a generally available feature.