Making a request strictly over cellular even when wifi is connected

Hello everyone,

Can someone help me understand how the following code works?

let params = NWParameters(tls: tlsOptions, tcp: tcpOptions)
params.requiredInterfaceType = .cellular

connection = NWConnection(to: connectionHostPort, using: params)

Does this configuration guarantee that all network calls made using the connection will always use cellular data? What happens if both WiFi and cellular are connected simultaneously? Is there any underlying UNIX library which can confirm this?


TIA arup[dot]s[at]icloud[dot]com

Answered by DTS Engineer in 802507022
Does this configuration guarantee that all network calls made using the connection will always use cellular data?

Yes.

What happens if both WiFi and cellular are connected simultaneously?

The connection will run over WWAN.

Is there any underlying UNIX library which can confirm this?

You can confirm this using Network framework itself, but monitoring the current path.

If you want completely independent confirmation, use a RVI packet trace. Or just turn off WWAN and notice that the connection will fail to go through.

ps I have a bunch of posts about this stuff, all referenced from Extra-ordinary Networking.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer
Does this configuration guarantee that all network calls made using the connection will always use cellular data?

Yes.

What happens if both WiFi and cellular are connected simultaneously?

The connection will run over WWAN.

Is there any underlying UNIX library which can confirm this?

You can confirm this using Network framework itself, but monitoring the current path.

If you want completely independent confirmation, use a RVI packet trace. Or just turn off WWAN and notice that the connection will fail to go through.

ps I have a bunch of posts about this stuff, all referenced from Extra-ordinary Networking.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Making a request strictly over cellular even when wifi is connected
 
 
Q