diff options
author | jfrijters <jfrijters> | 2011-08-24 13:07:19 +0400 |
---|---|---|
committer | jfrijters <jfrijters> | 2011-08-24 13:07:19 +0400 |
commit | eaaccdd4e95adb03091adfb4e7fc91bd12d72e94 (patch) | |
tree | cdb224b7a4e958fd16a3084134b6ab24292215ce /openjdk/java/net | |
parent | 60adc319391d03eba308e29fb8d95ebe00a82afa (diff) |
Implemented Asynchronous[Server]SocketChannel.
Diffstat (limited to 'openjdk/java/net')
-rw-r--r-- | openjdk/java/net/SocketUtil.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/openjdk/java/net/SocketUtil.java b/openjdk/java/net/SocketUtil.java index bd2d55cc..d9a30869 100644 --- a/openjdk/java/net/SocketUtil.java +++ b/openjdk/java/net/SocketUtil.java @@ -72,6 +72,11 @@ public final class SocketUtil public static IPAddress getAddressFromInetAddress(InetAddress addr) { + return getAddressFromInetAddress(addr, false); + } + + public static IPAddress getAddressFromInetAddress(InetAddress addr, boolean v4mapped) + { byte[] b = addr.getAddress(); if (b.length == 16) { @@ -79,6 +84,21 @@ public final class SocketUtil // (according to the documentation this was fixed in .NET 2.0) return new IPAddress(b); } + else if (v4mapped) + { + if (b[0] == 0 && b[1] == 0 && b[2] == 0 && b[3] == 0) + { + return IPAddress.IPv6Any; + } + byte[] b16 = new byte[16]; + b16[10] = -1; + b16[11] = -1; + b16[12] = b[0]; + b16[13] = b[1]; + b16[14] = b[2]; + b16[15] = b[3]; + return new IPAddress(b16); + } else { return new IPAddress((((b[3] & 0xff) << 24) + ((b[2] & 0xff) << 16) + ((b[1] & 0xff) << 8) + (b[0] & 0xff)) & 0xffffffffL); |