All Stream Sockets where you specify an bind address (different from InAddrAny aka "::" or 0.0.0.0) are only bound to a single address family. You can't bind a single listening socket to a dual stack localhost IP Address. getLoopbackAddress is either ::1 or 127.0.0.1 (depending on the stack preferemces) and InetAddress.getByName("localhost") is also one of both (but not necesarily the same, unfortunately). This happened to me in the past, so I wanted to make sure that asumption does not show up in sample code of JavaDocs. Thanks for improving this!
Bernd Am 22.08.2013 um 10:54 schrieb Alan Bateman <alan.bate...@oracle.com>: > On 22/08/2013 01:58, Stuart Marks wrote: >> Hi all, >> >> Please review this small documentation change to the example I added to >> RMISocketFactory a couple weeks ago [1]. This change fixes a problem that >> Bernd Eckenfels pointed out [2] where the interface returned by >> getLoopbackAddress() might not match the interface that "localhost" resolves >> to. > We don't have support for IPv4-only or IPv6-only listeners (at least not with > stream oriented sockets, there is support for protocol specific datagram > sockets but that doesn't apply here). So I'm curious about the original > comments and whether there are configurations or loopback address plumbing > where getLoopbackAddress doesn't do the right thing? > > -Alan