From f1c66f1be911336e947ba2acf3c324a82b4038be Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 09:54:40 +0000 Subject: Utilisateur : Fcolin Date : 5/02/04 Heure : 15:56 Archivé dans $/EScribe/Ivy Commentaire: (vss 22) --- CSharp/Ivy/IvyPPC/Ivy.cs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'CSharp/Ivy/IvyPPC/Ivy.cs') diff --git a/CSharp/Ivy/IvyPPC/Ivy.cs b/CSharp/Ivy/IvyPPC/Ivy.cs index 8775944..ec4e401 100644 --- a/CSharp/Ivy/IvyPPC/Ivy.cs +++ b/CSharp/Ivy/IvyPPC/Ivy.cs @@ -105,6 +105,26 @@ namespace IvyBus } } + internal class MyTcpListener : TcpListener + { + public MyTcpListener(IPAddress address, int port) : base(address, port) + { + //Socket s = this.Server; + // set Listen MaxConnections to 10 . + //IPOptions lingerOption = new IPOptions (true, 10); + + //s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MaxConnections , 10 ); + } + public void WaitForActive() + { + while( ! this.Active ) + { + Thread.Sleep( 50 ); + } + } + + + } /// the name of the application on the bus internal String appName; @@ -118,7 +138,7 @@ namespace IvyBus private bool debug; private static int serial = 0; /* an unique ID for each regexp */ - private TcpListener app; + private MyTcpListener app; private ArrayList watchers; private volatile Thread serverThread; // to ensure quick communication of the end private Hashtable callbacks; @@ -194,7 +214,7 @@ namespace IvyBus domainbus = DEFAULT_DOMAIN; try { - app = new TcpListener(0); + app = new MyTcpListener(IPAddress.Any,0); app.Start(); applicationPort = ((IPEndPoint) app.LocalEndpoint).Port; } @@ -215,6 +235,7 @@ namespace IvyBus serverThread = new Thread(new ThreadStart(this.Run)); serverThread.Name = "Ivy Tcp Server Thread"; serverThread.Start(); + app.WaitForActive(); // sends the broadcasts and listen to incoming connexions for (int i = 0; i < watchers.Count; i++) { -- cgit v1.1