解决java网络编程IPv6带来的问题方法
时间:2010-09-01 来源:Snowfun
以前用jgroups以及mantaray都碰到过这样的问题,蹩脚的做法禁止IPv6协议,今天学到的一招解决网络编程IPv6带来的问题!设置一个属性就可以了
-Djava.net.preferIPv4Stack=true
以后用jgroups可以设置一下就可以了,查阅sun官方文档解释如下:
java.net.preferIPv4Stack (default: false)
If IPv6 is available on the operating system the underlying native socket will be an IPv6 socket. This allows Java(tm) applications to connect too, and accept connections from, both IPv4 and IPv6 hosts.
If an application has a preference to only use IPv4 sockets then this property can be set to true. The implication is that the application will not be able to communicate with IPv6 hosts.
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/stanyang/archive/2006/09/22/1265121.aspx
-Djava.net.preferIPv4Stack=true
以后用jgroups可以设置一下就可以了,查阅sun官方文档解释如下:
java.net.preferIPv4Stack (default: false)
If IPv6 is available on the operating system the underlying native socket will be an IPv6 socket. This allows Java(tm) applications to connect too, and accept connections from, both IPv4 and IPv6 hosts.
If an application has a preference to only use IPv4 sockets then this property can be set to true. The implication is that the application will not be able to communicate with IPv6 hosts.
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/stanyang/archive/2006/09/22/1265121.aspx
相关阅读 更多 +