From 58a4790b0859a23990bc747432365ba797c9a522 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 10:03:20 +0000 Subject: Utilisateur : Fcolin Date : 30/06/05 Heure : 14:21 Archivé dans $/CSharp/Ivy Commentaire: Bug start time < 0 en l'absence de rejeu a voir ajouter 1s de blank au debut (vss 8) --- CSharp/Ivy/IvyPPC/IvyWatcher.cs | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'CSharp/Ivy/IvyPPC') diff --git a/CSharp/Ivy/IvyPPC/IvyWatcher.cs b/CSharp/Ivy/IvyPPC/IvyWatcher.cs index ee67ea3..caac8b7 100644 --- a/CSharp/Ivy/IvyPPC/IvyWatcher.cs +++ b/CSharp/Ivy/IvyPPC/IvyWatcher.cs @@ -88,34 +88,38 @@ namespace IvyBus bool running = true; while (running) { - int port; try { len = broadcast.ReceiveFrom(buf, ref tempRemoteEP); // I was summoned to leave during the receive - String msg = Encoding.ASCII.GetString(buf); + String msg = Encoding.ASCII.GetString(buf,0,len); remoteEP = (IPEndPoint)tempRemoteEP; IPAddress remotehost = remoteEP.Address; traceDebug("BUSWATCHER Receive Broadcast from " + Dns.GetHostName() + ":" + remoteEP.Port); - // TODO if ( !isInDomain( remotehost ) ) continue; - String[] st = msg.Split(new char[]{' ','\n'},3); - if (st.Length != 3) + //TODO if ( !isInDomain( remotehost ) ) continue; + String[] st = msg.Split(new char[]{' ','\n'},4); + if (st.Length != 4) { Console.Error.WriteLine("Bad format " + msg); continue; } int version = Int32.Parse(st[0]); - port = Int32.Parse(st[1]); + int port = Int32.Parse(st[1]); + string appId = st[2]; + string appName = st[3]; if (version != Ivy.PROCOCOLVERSION) { Console.Error.WriteLine("Ignoring bad protocol version broadcast"); continue; } - if ((bus.applicationPort == port)) + if ((bus.applicationPort == port)) // self Broadcast continue; - traceDebug("BUSWATCHER Broadcast de " + Dns.GetHostName() + ":" + remoteEP.Port + " port " + port + " version " + version); + traceDebug("BUSWATCHER Broadcast de " + Dns.GetHostName() + ":" + remoteEP.Port + " port " + port + + " version " + version + + " id " + appId + + " name " + appName); try { Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); @@ -130,17 +134,22 @@ namespace IvyBus } catch (IOException jii) { + Console.Error.WriteLine("UDP listener " + jii.Message); running = false; } +// catch (SocketException se) +// { +// traceDebug( "watcher socket closed: " + se.Message); +// } } // while } catch (SocketException se) { - traceDebug( "watcher socket closed" ); + traceDebug( "watcher socket closed: " + se.Message); } catch (IOException ioe) { - Console.Error.WriteLine( ioe.StackTrace ); + traceDebug( "watcher thread ended: " + ioe.Message); } traceDebug("end of a watcher thread"); } @@ -167,7 +176,7 @@ namespace IvyBus { lock(this) { - String hello = Ivy.PROCOCOLVERSION + " " + bus.applicationPort + "\n"; + String hello = Ivy.PROCOCOLVERSION + " " + bus.applicationPort + " " + bus.AppId + " " + bus.AppName + "\n"; listenThread.Start(); byte[] hellob = Encoding.ASCII.GetBytes( hello ); IPEndPoint EPhost = new IPEndPoint(group, port); -- cgit v1.1