From 4826af957608a54e4492815551f39ac543258fd1 Mon Sep 17 00:00:00 2001 From: jestin Date: Mon, 6 Aug 2001 14:33:34 +0000 Subject: Adding multicast ( IvyWatcher ), adding the new IvyDaemon program, removing the debug code in Probe, and who knows what I've done in IvyClient ? --- src/IvyWatcher.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/IvyWatcher.java') diff --git a/src/IvyWatcher.java b/src/IvyWatcher.java index bae387a..2fe0bfd 100755 --- a/src/IvyWatcher.java +++ b/src/IvyWatcher.java @@ -24,10 +24,11 @@ class IvyWatcher implements Runnable { private static boolean debug = (System.getProperty("IVY_DEBUG")!=null); private Vector domainaddrList; private boolean watcherrunning = false; + private boolean isMulticastAddress = false; private Thread broadcastListener ; private Ivy bus; /* master bus controler */ private DatagramSocket broadcast; /* supervision socket */ - + // it can also be a MulticastSocket, which inherits from the previous /** * creates an Ivy watcher. * @param bus the bus @@ -135,12 +136,19 @@ class IvyWatcher implements Runnable { port = Integer.parseInt( domain.substring( sep_index +1 )); domainaddr = domain.substring(0,sep_index); } - // create the UDP socket + // Handling of multicast address try { - broadcast = new MulticastSocket(port ); + InetAddress group = InetAddress.getByName(domainaddr); + if (group.isMulticastAddress()) { + isMulticastAddress = true; + broadcast = new MulticastSocket(port ); // create the UDP socket + ((MulticastSocket)broadcast).joinGroup(group); + } else { + broadcast = new MulticastSocket(port ); // create the UDP socket + } } catch ( IOException e ) { - throw new IvyException("IvyWatcher erreur I/O" + e ); - } + throw new IvyException("IvyWatcher I/O error" + e ); + } // starts a Thread listening on the socket watcherrunning=true; broadcastListener = new Thread(this); -- cgit v1.1