JDK1.4.2 不使用 getHostAddress 返回 IPV6 地址
JDK 1.5 以上可以正常返回 IPV6 地址。但JDK1.4.2仅返回IPV4地址。操作系统是Windows XP和Windows 7。有人设法在JDK 1.4.2上获取IPV6地址吗?
NetworkInterface iface = null;
for (Enumeration ifaces = NetworkInterface.getNetworkInterfaces(); ifaces
.hasMoreElements();) {
iface = (NetworkInterface) ifaces.nextElement();
InetAddress ia = null;
for (Enumeration ips = iface.getInetAddresses(); ips
.hasMoreElements();) {
ia = (InetAddress) ips.nextElement();
System.out.println(ia.getHostName());
}
}
我怀疑 java.net.InetAddressImplFactory 中有这个本机代码。
private static native boolean isIPv6Supported();
由于JDK1.4.2开发较早,可能与Windows中获取IPV6地址的原生库不兼容。这是正确的吗?
JDK 1.5 above returns the IPV6 addresses fine. But JDK1.4.2 returns only IPV4 addresses. The OS are Windows XP and Windows 7. Anyone manages to get the IPV6 addresses on JDK 1.4.2?
NetworkInterface iface = null;
for (Enumeration ifaces = NetworkInterface.getNetworkInterfaces(); ifaces
.hasMoreElements();) {
iface = (NetworkInterface) ifaces.nextElement();
InetAddress ia = null;
for (Enumeration ips = iface.getInetAddresses(); ips
.hasMoreElements();) {
ia = (InetAddress) ips.nextElement();
System.out.println(ia.getHostName());
}
}
I am suspicious that there is this native code in java.net.InetAddressImplFactory.
private static native boolean isIPv6Supported();
Since JDK1.4.2 was developed long time ago, it might not be compatible with the native library in Windows to get the IPV6 addresses. Is this correct?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论