InetAddress - is it broken??

Michael Koch konqueror@gmx.de
Tue Jun 17 11:49:00 GMT 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Am Donnerstag, 12. Juni 2003 21:56 schrieb Craig A. Vanderborgh:
> Hello gcjland:
>> I have discovered the following apparently malignant behavior in
> InetAddress.getLocalHost() on linux. Given the following brainless
> test program:
>> import java.net.*;
>> public class InetAddressTest {
> public static void main(String[] args) {
> System.out.println("getting local host address..");
> try {
> InetAddress address = InetAddress.getLocalHost();
> System.out.println(address);
> } catch (UnknownHostException e) {
> System.out.println("Could not find local address");
> }
>> }
> }
>> What I see is this:
> getting local host address..
> zetar/127.0.0.1
>> The environment is x86linux (RedHat 8.0), gcc/gcj version as
> follows: gcj (GCC) 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
>> All documentation I have, as well as relevant experience, suggests
> that this is incorrect. Perhaps my expectations are incorrect,
> however.
>> Please advise.

I just tried it here. With GCJ it returns:
getting local host address..
asterix.konqueror.de/192.168.1.3
With SUNs JDK 1.4.1_01 it returns:
getting local host address..
asterix/192.168.1.3
I dont know why your IP is 127.0.0.1. Perhaps your /etc/hosts is 
configured braindead.
Michael
- -- 
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE+7vReWSOgCCdjSDsRApKZAJ0dX+6ezqpxO7a5WHqpFZQRNa+owQCfdbqi
MS7qmhNMYFMQw28Y1jFKQyk=
=8t4l
-----END PGP SIGNATURE-----


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /