其实这个问题不光是
ServerSocketChannel,还有SocketChannel connect一ipv6地址时,同样产生异常
代码如下:
protected final ServerSocketChannel ssc;
private int ListenPort=8088;
...
this.ssc = ServerSocketChannel.open();
this.ssc.configureBlocking(false);
local6Address=(Inet6Address)Inet6Address.getByName("2001:250:f007:1:f1ea:dada:9b57:9596");
InetSocketAddress inetSocketAddress=new InetSocketAddress(local6Address,this.ListenPort);try {
this.ssc.socket().bind(inetSocketAddress);
}catch (IOException e){
System.err.println("the socket exception");
e.printStackTrace();
}产生异常:
java.net.SocketException: Address family not supported by protocol family: bind
at sun.nio.ch.Net.bind(Native Method)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:119)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:52)
ServerSocketChannel,还有SocketChannel connect一ipv6地址时,同样产生异常
代码如下:
protected final ServerSocketChannel ssc;
private int ListenPort=8088;
...
this.ssc = ServerSocketChannel.open();
this.ssc.configureBlocking(false);
local6Address=(Inet6Address)Inet6Address.getByName("2001:250:f007:1:f1ea:dada:9b57:9596");
InetSocketAddress inetSocketAddress=new InetSocketAddress(local6Address,this.ListenPort);try {
this.ssc.socket().bind(inetSocketAddress);
}catch (IOException e){
System.err.println("the socket exception");
e.printStackTrace();
}产生异常:
java.net.SocketException: Address family not supported by protocol family: bind
at sun.nio.ch.Net.bind(Native Method)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:119)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:52)
还是没有人会解决?
我这个程序运行在xp sp2系统上
我是使用了DatagramSocket来建立连接,结果总是无法取得IPv6的地址连接。
即使本地的也失败。
你有mail吗?我的mail是[email protected]
可以否?
而且,IPv4的地址和IPv6的地址同时被绑定了。可以同时使用。
我的email
[email protected]
或
[email protected]