Control IP version of URLSession

When connecting to a URL using URLSession, is it possible to somehow control if URLSession should pick an IPv4 or IPv6 address?

I have a URL and I need to make two connections to the URL, one using IPv4 and one using IPv6. The DNS name used in the URL resolves to both IPv4 and IPv6 addresses and I can't change this.

Is there any way to affect which IP version (or IP number in general) that URLSession picks when resolving the name?

When connecting to a URL using URLSession, is it possible to somehow
control if URLSession should pick an IPv4 or IPv6 address?

Not really. You could build the URL to reference the IP address rather than the DNS name, but that won’t work in all situations.

Share and Enjoy

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

I ended up using a third party WebSocket library.

It would be good if we were able to change the Host header of the URLRequest when the URL itself contains an IP number instead of a DNS name.

It would be good if we were able to change the Host header of the
URLRequest when the URL itself contains an IP number instead of a
DNS name.

I’ve seen other folks offer similar opinions, and my recommendation is that you file an enhancement request along those lines.

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Control IP version of URLSession
 
 
Q