[4683] in java-interest

home help back first fref pref prev next nref lref last post

Re: misplaced method

daemon@ATHENA.MIT.EDU (Jim Graham)
Wed Jan 10 20:38:35 1996

Date: Wed, 10 Jan 1996 16:19:03 -0800
From: flar@bendenweyr.Eng.Sun.COM (Jim Graham)
To: java-interest@java.Eng.Sun.COM, elliotte@blackstar.com
Cc: Arthur.Vanhoff@Eng.Sun.COM


> > Try this, you need to convert the IP address to a string though:
> > 
> >   String host = getByName("129.144.86.116").getHostName();
> 
> 
> This only seems to return the numeric IP address formatted as a 
> String, e.g. "199.1.32.90" instead of "star.blackstar.com". Is there 
> anyway to get the host name back?

getHostName() is the correct interface, but there is a bug in getByName
that sets the hosts "name" to the IP address so that getHostName
just returns it rather than doing the reverse lookup.

This should work:

	byte addr[] = {129, 144, 86, 116};
	String host = new InetAddress(null, addr).getHostName();

				...jim
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post