[integration] Fixes for the IPv6 code

This patches the IPv6 code so that it uses the system-wide ordering of addresses and fixes a major bug in the connection code which prevents things from connecting at all, even over IPv4.