diff options
author | Michael Koch <konqueror@gmx.de> | 2004-11-17 07:09:57 +0000 |
---|---|---|
committer | Michael Koch <mkoch@gcc.gnu.org> | 2004-11-17 07:09:57 +0000 |
commit | 879245b6b2b2305dda94c05009b431a007be5021 (patch) | |
tree | 6e34644be784f7f8c67bcab04e74d439de258383 /libjava/java | |
parent | 7c8347536fcd9cf01264aba9a3827915f26de05d (diff) | |
download | gcc-879245b6b2b2305dda94c05009b431a007be5021.zip gcc-879245b6b2b2305dda94c05009b431a007be5021.tar.gz gcc-879245b6b2b2305dda94c05009b431a007be5021.tar.bz2 |
InetAddress.java (getCanonicalHostName): Support IPv6 addresses.
2004-11-17 Michael Koch <konqueror@gmx.de>
* java/net/InetAddress.java (getCanonicalHostName):
Support IPv6 addresses.
From-SVN: r90793
Diffstat (limited to 'libjava/java')
-rw-r--r-- | libjava/java/net/InetAddress.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libjava/java/net/InetAddress.java b/libjava/java/net/InetAddress.java index 24743cc..3306803 100644 --- a/libjava/java/net/InetAddress.java +++ b/libjava/java/net/InetAddress.java @@ -322,8 +322,14 @@ public class InetAddress implements Serializable } // Try to find the FDQN now - // FIXME: This does not work with IPv6. - InetAddress address = new Inet4Address(getAddress(), null); + InetAddress address; + byte[] ipaddr = getAddress(); + + if (ipaddr.length == 16) + address = new Inet6Address(getAddress(), null); + else + address = new Inet4Address(getAddress(), null); + return address.getHostName(); } |