From 64c95fd653177361f7e691ab345ed54d42ef6aed Mon Sep 17 00:00:00 2001 From: jestin Date: Mon, 12 Jan 2004 09:48:49 +0000 Subject: 1.2.5 pre --- src/IvyWatcher.java | 91 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 59 insertions(+), 32 deletions(-) (limited to 'src/IvyWatcher.java') diff --git a/src/IvyWatcher.java b/src/IvyWatcher.java index 98956ea..7698632 100755 --- a/src/IvyWatcher.java +++ b/src/IvyWatcher.java @@ -14,6 +14,17 @@ * thing. * * CHANGELOG: + * 1.2.5: + * - getDomain now sends IvyException for malformed broadcast addresses + * 1.2.4: + * - sends the broadcast before listening to the other's broadcasts. + * TODO wait for all the broadcast to be sent before starting the listen + * mode + * - (REMOVED) allows the connexion from a remote host with the same port number + * it's too complicated to know if the packet is from ourselves... + * - deals with the protocol errors in a more efficient way. The goal is not + * to loose our connectivity because of a rude agent. + * fixes Bug J005 (YJ + JPI) * 1.2.3: * - the packet sending is done in its own thread from now on (PacketSender) * I don't care stopping it, since it can't be blocked. @@ -51,6 +62,7 @@ class IvyWatcher implements Runnable { private boolean isMulticastAddress = false; private Ivy bus; /* master bus controler */ private DatagramSocket broadcast; /* supervision socket */ + private InetAddress localhost,loopback; private String domainaddr; private int port; private volatile Thread listenThread; @@ -75,6 +87,9 @@ class IvyWatcher implements Runnable { ((MulticastSocket)broadcast).joinGroup(group); } broadcast.setSoTimeout(Ivy.TIMEOUTLENGTH); + localhost=InetAddress.getLocalHost(); + loopback=InetAddress.getByName(null); + } catch ( UnknownHostException uhe ) { } catch ( IOException e ) { throw new IvyException("IvyWatcher I/O error" + e ); } @@ -89,9 +104,9 @@ class IvyWatcher implements Runnable { traceDebug("beginning of a watcher Thread"); byte buf[] = new byte[256]; DatagramPacket packet=new DatagramPacket(buf, 256); + InetAddress remotehost=null; try { while( listenThread==thisThread ) { - int port; try { broadcast.receive(packet); if (listenThread!=thisThread) break; // I was summoned to leave during the receive @@ -99,37 +114,43 @@ class IvyWatcher implements Runnable { for (int i=0;i