From 2a18d2c886bd31ffc52cfc7f79e85a2d96037936 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 10:03:48 +0000 Subject: Utilisateur : Fcolin Date : 10/02/06 Heure : 15:34 Archivé dans $/CSharp/Ivy/Ivy Commentaire: symplification traitement exception (vss 22) --- CSharp/Ivy/IvyPPC/IvyWatcher.cs | 82 ++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 47 deletions(-) diff --git a/CSharp/Ivy/IvyPPC/IvyWatcher.cs b/CSharp/Ivy/IvyPPC/IvyWatcher.cs index b943b21..0db24aa 100644 --- a/CSharp/Ivy/IvyPPC/IvyWatcher.cs +++ b/CSharp/Ivy/IvyPPC/IvyWatcher.cs @@ -90,57 +90,45 @@ namespace IvyBus bool running = true; while (running) { - try - { + ushort version; + ushort port; + string appId; + string appName; + IPEndPoint remoteEP; - ushort version; - ushort port; - string appId; - string appName; - IPEndPoint remoteEP; - - stream.receiveMsg(out remoteEP, out version,out port,out appId,out appName); - IPAddress remotehost = remoteEP.Address; - traceDebug("BUSWATCHER Receive Broadcast from " + Dns.GetHostEntry(remotehost).HostName + ":" + remoteEP.Port); + stream.receiveMsg(out remoteEP, out version, out port, out appId, out appName); + IPAddress remotehost = remoteEP.Address; + traceDebug("BUSWATCHER Receive Broadcast from " + Dns.GetHostEntry(remotehost).HostName + ":" + remoteEP.Port); - //TODO if ( !isInDomain( remotehost ) ) continue; + //TODO if ( !isInDomain( remotehost ) ) continue; - if (version != stream.ProtocolVersion) - { - traceDebug("Ignoring bad protocol version "+ version + " expected " + stream.ProtocolVersion); - continue; - } + if (version != stream.ProtocolVersion) + { + traceDebug("Ignoring bad protocol version " + version + " expected " + stream.ProtocolVersion); + continue; + } - // filtrage des self Broadcast - if ( appId == bus.AppId ) - continue; - if ( (port == bus.applicationPort) && (remotehost.Equals(bus.applicationHost)) ) - continue; - traceDebug("BUSWATCHER reponse au Broadcast de " + Dns.GetHostEntry(remotehost).HostName + ":" + remoteEP.Port + " port " + port + - " version " + version + - " id " + appId + - " name " + appName); - try - { - Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - IPEndPoint hostEndPoint = new IPEndPoint(remoteEP.Address, port); - socket.Connect(hostEndPoint); - bus.addClient(socket,appName); - } - catch (Exception e) - { - traceDebug("can't connect to " + remotehost + " port " + port + " \n" + e.Message); - } - } - catch (IOException jii) - { - traceDebug("UDP listener " + jii.Message); - running = false; - } -// catch (SocketException se) -// { -// traceDebug( "watcher socket closed: " + se.Message); -// } + // filtrage des self Broadcast + if (appId == bus.AppId) + continue; + if ((port == bus.applicationPort) && (remotehost.Equals(bus.applicationHost))) + continue; + traceDebug("BUSWATCHER reponse au Broadcast de " + Dns.GetHostEntry(remotehost).HostName + ":" + remoteEP.Port + " port " + port + + " version " + version + + " id " + appId + + " name " + appName); + try + { + Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + IPEndPoint hostEndPoint = new IPEndPoint(remoteEP.Address, port); + socket.Connect(hostEndPoint); + bus.addClient(socket, appName); + } + catch (Exception e) + { + traceDebug("can't connect to " + remotehost + " port " + port + " \n" + e.Message); + } + } // while } catch (SocketException se) -- cgit v1.1