Post

Replies

Boosts

Views

Activity

NWConnection how to force ipv4 ?
 I have the following code to force the connectivity over cellular and it works perfectly 	 let tcpOptions = NWProtocolTCP.Options()     tcpOptions.connectionTimeout = 5     var tlsOptions: NWProtocolTLS.Options?     var port = 80     if (url.scheme!.starts(with:"https")) {       port = 443       tlsOptions = .init()     }     /*force network connection to cellular only*/     let params = NWParameters(tls: tlsOptions , tcp: tcpOptions)     params.requiredInterfaceType = .cellular     params.prohibitExpensivePaths = false     params.prohibitedInterfaceTypes = [.wifi]     /* create network connection */     connection = NWConnection(host: NWEndpoint.Host(url.host!), port: NWEndpoint.Port(rawValue: UInt16(port))!, using: params) Now I'm looking to force the connection to use ipv4 (even if the phone has an ipv6 available) because the targeted server has a broken ipv6 support and I don't have control over it (it belongs to a mobile operator) Any idea? E
10
0
3.8k
Oct ’23