As an Internet Lorax, I beg you to reconsider this algorithm. Pretend that it's a few years in the future, and most ISPs are using Carrier Grade NAT for IPv4 access. We need to ensure that IPv6 remains a practical alternative to building more NAT capacity, and that requires cooperation from the client-side software.
This patch makes curl send out IPv4 and IPv6 SYNs simultaneously, which means that even on a fully dual-stack network, every request creates state in the NAT. Worse, preferring IPv4 requires the NAT to track the entire session in the majority of cases. In the Prisoner's Dilemma sense, this algorithm chooses "defect." Here's an alternative algorithm that's simple and effective; Chrome does something similar: - Connect to the first address returned by getaddrinfo(). - After 300ms, connect to an address of the opposite family. - When one connection succeeds, abort the other. References: [1] http://tools.ietf.org/html/rfc6555#section-4.1 [2] https://code.google.com/p/chromium/issues/detail?id=81686#c12 [3] https://labs.ripe.net/Members/emileaben/hampered-eyeballs ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.html