Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 May 2003 17:01:59 +0100 (BST)
From:      Jan Grant <Jan.Grant@bristol.ac.uk>
To:        Sheldon Hearn <sheldonh@starjuice.net>
Cc:        freebsd-java@freebsd.org
Subject:   Re: Question about native 1.4.1, InetAddress.getLocalHost() - bug?
Message-ID:  <Pine.GSO.4.44.0305021652390.6782-100000@mail.ilrt.bris.ac.uk>
In-Reply-To: <20030409182725.GS9708@starjuice.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 9 Apr 2003, Sheldon Hearn wrote:

> On (2003/04/09 18:36), Jan Grant wrote:
>
> > Should this do what I think it should? When I created a ServerSocket
> > using
> >
> > 	s = new ServerSocket(1234, 0, InetAddress.getLocalHost());
> >
> > I wound up with netstat reporting that I had a TCP connection listening
> > on 192.168.0.1.1234. From the description of the call, I'd expect
> > to see it listening on 127.0.0.1.1234.
>
> I must admit, I'd expect any IP address bound to a local interface to be
> valid.  In other words, I'd expect to see what you're seeing.
>
> Note that jre-1.4.1 on Windows gives the same results.
>
> Note that the API documentation says that getLocalHost() returns IP
> address of "the local host", not "localhost".  This is vague in the
> context of hosts with multiple local addresses.

Tell me about it. I've just reexamined the documentation and it includes
this:

[[
If the operation is not allowed, an InetAddress representing the
loopback address is returned.
]]

I'd not parsed this sentence correctly initially; I'd focussed on the
second clause not the first one. Seems braindead to me, but it's clearly
not a FBSD-specific issue. Cheers.


-- 
jan grant, ILRT, University of Bristol. http://www.ilrt.bris.ac.uk/
Tel +44(0)117 9287088 Fax +44 (0)117 9287112 http://ioctl.org/jan/
(Things I've found in my attic, #2: A hundredweight of pornography.)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.44.0305021652390.6782-100000>