Mercurial > hg > Applications > TreeVNC
changeset 263:4075f68f1c91
add joinGroup IPv6 and IPv4 adderss version.
author | oc |
---|---|
date | Mon, 08 Dec 2014 16:09:24 +0900 |
parents | 7d8f45cadd89 |
children | 83d0256a8808 |
files | src/main/java/jp/ac/u_ryukyu/treevnc/TreeRootFinderListener.java src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncCommandChannelListener.java |
diffstat | 2 files changed, 12 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRootFinderListener.java Mon Dec 08 04:48:23 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRootFinderListener.java Mon Dec 08 16:09:24 2014 +0900 @@ -9,7 +9,10 @@ import com.glavsoft.viewer.swing.ConnectionParams; public class TreeRootFinderListener implements Runnable { - public static final String McastAddr = "FF02::1"; + public static final String Ipv4McastAddr = "224.0.0.1"; + public static final String Ipv6McastAddr = "FF02::1"; + public static String McastAddr = Ipv4McastAddr; + static final int BufSize = 1024; private boolean stopFlag = false; private ViewerInterface vps; @@ -27,10 +30,14 @@ private void replyToRootSearchMulticast() { byte[] buf = new byte[BufSize]; try { - InetAddress mAddr = InetAddress.getByName(McastAddr); soc = new MulticastSocket(ConnectionParams.DEFAULT_VNC_ROOT_FINDER); - SocketAddress socAdd = new InetSocketAddress(mAddr, 5900); - soc.joinGroup(socAdd, null); + try { + soc.joinGroup(InetAddress.getByName(McastAddr)); + } catch (SocketException e) { + soc.joinGroup(InetAddress.getByName(Ipv6McastAddr)); + McastAddr = Ipv6McastAddr; + } + DatagramPacket recvPacket = new DatagramPacket(buf, BufSize); while (!stopFlag) { soc.receive(recvPacket);
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncCommandChannelListener.java Mon Dec 08 04:48:23 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncCommandChannelListener.java Mon Dec 08 16:09:24 2014 +0900 @@ -100,7 +100,7 @@ * initial connection of RFB protocol */ InetAddress adr = connection.getLocalAddress(); - String myHostAddress =adr .getHostAddress(); + String myHostAddress = adr.getHostAddress(); String intf = NetworkInterface.getByInetAddress(adr).getName(); sendRfbVersion(os); byte[] b;