There are instances where the host machine does not have IPv6 connectivity and DNS returns both IPv6 and IPv4 addresses. The order of the returned addresses is random - first entry might be IPv6 and second entry might be IPv4, e.g.:
In this case, the code only tried resolving Address 1, which resulted with failure, because the host machine did not have IPv6 connectivity:
cannot connect: Network is unreachable
This commit changes the behaviour by iterating over all returned resolved addresses and trying to connect to all of them until it eventually succeeds or fails if none of the addresses could be connected to.
There are instances where the host machine does not have IPv6 connectivity and DNS returns both IPv6 and IPv4 addresses. The order of the returned addresses is random - first entry might be IPv6 and second entry might be IPv4, e.g.:
In this case, the code only tried resolving
Address 1
, which resulted with failure, because the host machine did not have IPv6 connectivity:This commit changes the behaviour by iterating over all returned resolved addresses and trying to connect to all of them until it eventually succeeds or fails if none of the addresses could be connected to.