diff options
author | fcolin | 2007-02-01 10:03:20 +0000 |
---|---|---|
committer | fcolin | 2007-02-01 10:03:20 +0000 |
commit | 58a4790b0859a23990bc747432365ba797c9a522 (patch) | |
tree | 7dc216efd9e127824c587e64befc35d9300abc61 | |
parent | 5316d2e39a94854e8a39c2d616e06da83a80f8f4 (diff) | |
download | ivy-csharp-58a4790b0859a23990bc747432365ba797c9a522.zip ivy-csharp-58a4790b0859a23990bc747432365ba797c9a522.tar.gz ivy-csharp-58a4790b0859a23990bc747432365ba797c9a522.tar.bz2 ivy-csharp-58a4790b0859a23990bc747432365ba797c9a522.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)
-rw-r--r-- | CSharp/Ivy/IvyPPC/IvyWatcher.cs | 31 |
1 files changed, 20 insertions, 11 deletions
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);
|