以前用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.