summaryrefslogtreecommitdiff
path: root/CSharp
diff options
context:
space:
mode:
Diffstat (limited to 'CSharp')
-rw-r--r--CSharp/Ivy/IvyPPC/IvyWatcher.cs82
1 files 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)