Mercurial > hg > FederatedLinda
changeset 45:9a9414141346
*** empty log message ***
author | kono |
---|---|
date | Mon, 27 Oct 2008 08:55:17 +0900 |
parents | 4287c9c076de |
children | 98c2bbeaecb4 |
files | src/fdl/FDLindaServ.java |
diffstat | 1 files changed, 10 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/fdl/FDLindaServ.java Sun Oct 26 22:19:52 2008 +0900 +++ b/src/fdl/FDLindaServ.java Mon Oct 27 08:55:17 2008 +0900 @@ -2,8 +2,8 @@ package fdl; import java.io.IOException; -import java.net.InetAddress; import java.net.InetSocketAddress; +import java.net.SocketException; import java.nio.channels.ClosedChannelException; import java.nio.channels.SelectionKey; import java.nio.channels.ServerSocketChannel; @@ -63,11 +63,16 @@ selector = SelectorProvider.provider().openSelector(); //ソケット・チャネルを生成・設定 ssChannel = SelectorProvider.provider().openServerSocketChannel(); - // getAllByName で、すべて取って、その上のすべてでselectする必要がある。 - //InetSocketAddress address = new InetSocketAddress(InetAddress.getLocalHost(), port); - InetSocketAddress address = new InetSocketAddress("::", port); ssChannel.socket().setReuseAddress(true); - ssChannel.socket().bind(address); + // this should work for IPv6/IPv4 dual stack + // check this using netstat -an result tcp46. + try { + InetSocketAddress address = new InetSocketAddress("::", port); + ssChannel.socket().bind(address); + } catch (SocketException e) { + // for some bad IPv6 implementation + ssChannel.socket().bind(new InetSocketAddress(port)); + } ssChannel.configureBlocking(false); this.log(Level.INFO,"Server: litening at "+ssChannel); //セレクタにチャンネルを登録