Apple platforms have a connect-by-name infrastructure that intelligently handles servers with multiple IP addresses, supporting arbitrary mixes of both IPv4 and IPv6. The exact mechanics of this has changed over time. This post describes the approach used by OS X 10.7 (equivalent to iOS 5), but keep in mind that things have moved on a bit since then.
If you’re creating software for Apple platforms the take-home message is that you should use a high-level API that takes advantage of this connect-by-name infrastructure. That means CFSocketStream or anything layered on top of that, most notably, NSURLSession.
If you don’t use these high-level APIs then you have extra work to do. At a minimum you must use a DNS API that supports IPv4 and IPv6 (typically
getaddrinfo
) and try each address returned by that routine until you manage to connect. You can improve that by implementing
Happy Eyeballs. Better yet, you can cut the ‘head’ off your BSD Sockets code and wire it up to the connect-by-name infrastructure, as described by
this post.
If you’re looking for advice on how to set up your server’s DNS, I’m not really the right person to answer that. However, my expectation is that naïve approaches like round-robin DNS will provide no significant gain to any modern Apple clients.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"