diff options
author | fcolin | 2007-02-01 09:51:31 +0000 |
---|---|---|
committer | fcolin | 2007-02-01 09:51:31 +0000 |
commit | 5b07cdad68c7d1fb9da8a3b963dd749cc833b59a (patch) | |
tree | 78967a66a687dfbbf0ca70da674fa3fa3060a42b /CSharp/Ivy | |
parent | e33a8b3ef072914fc790de6bb01dc978ee3fe344 (diff) | |
download | ivy-csharp-5b07cdad68c7d1fb9da8a3b963dd749cc833b59a.zip ivy-csharp-5b07cdad68c7d1fb9da8a3b963dd749cc833b59a.tar.gz ivy-csharp-5b07cdad68c7d1fb9da8a3b963dd749cc833b59a.tar.bz2 ivy-csharp-5b07cdad68c7d1fb9da8a3b963dd749cc833b59a.tar.xz |
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)
Diffstat (limited to 'CSharp/Ivy')
-rw-r--r-- | CSharp/Ivy/Ivy/IvyWatcher.cs | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/CSharp/Ivy/Ivy/IvyWatcher.cs b/CSharp/Ivy/Ivy/IvyWatcher.cs index ee67ea3..caac8b7 100644 --- a/CSharp/Ivy/Ivy/IvyWatcher.cs +++ b/CSharp/Ivy/Ivy/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);
|