I’m using BSD sockets, and while I imagine it’s easy to determine if a user’s OS supports IPv6 (by trying to make a socket with AF_INET6), I’m not sure how to programmatically determine if their router or ISP doesn’t support such a connection. Will the connection simply fail, and if so, how do I distinguish that failure from a server simply being offline?
Share
As Ulrich Drepper says in his Userlevel IPv6 Programming Introduction, you should call
getaddrinfowith theAI_ADDRCONFIGflag set (which ensures you will only get address types currently configured on the system), then try each result in order until one succeeds (as the results are sorted, with the first most likely to succeed, and so forth) or all fail.