diff options
author | fcolin | 2007-02-01 09:51:59 +0000 |
---|---|---|
committer | fcolin | 2007-02-01 09:51:59 +0000 |
commit | 2843db30512d3c6aea23a16929fb8f1e8611462a (patch) | |
tree | da71a86ed64e9ade14a883b9bc9896a9ebef6633 | |
parent | df6b53424691502238946f3ffec3c477b8c730d1 (diff) | |
download | ivy-csharp-2843db30512d3c6aea23a16929fb8f1e8611462a.zip ivy-csharp-2843db30512d3c6aea23a16929fb8f1e8611462a.tar.gz ivy-csharp-2843db30512d3c6aea23a16929fb8f1e8611462a.tar.bz2 ivy-csharp-2843db30512d3c6aea23a16929fb8f1e8611462a.tar.xz |
Utilisateur : Fcolin Date : 10/02/06 Heure : 15:34 Archivé dans $/CSharp/Ivy/Ivy Commentaire: symplification traitement exception (vss 22)
-rw-r--r-- | CSharp/Ivy/Ivy/IvyWatcher.cs | 82 |
1 files changed, 35 insertions, 47 deletions
diff --git a/CSharp/Ivy/Ivy/IvyWatcher.cs b/CSharp/Ivy/Ivy/IvyWatcher.cs index b943b21..0db24aa 100644 --- a/CSharp/Ivy/Ivy/IvyWatcher.cs +++ b/CSharp/Ivy/Ivy/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)
|