On 28/11/2011 06:52, Charles Lee wrote:
Hi guys,
When we call InetAddress.getLocalHost(), we usually return the first
entry of inet address array. The array keeps the same order as
getaddrinfo gets (duplication has been removed).
In Windows 2008 sp2 or later version Windows OS with multiple NICs,
getaddrinfo() sorts the Addresses and linklocal/APIPA address appears
first now. So user will get a APIPA address even if a more useful
address is available.
I'm curious about this behavior. Are you saying that the host's name
resolves to addresses on all interfaces? Also I thought that the default
was to sort the addresses so that IPv4 addresses appear before IPv6
addresses (unless java.net.preferIPv6Addresses is set to true).
-Alan