summaryrefslogtreecommitdiff
path: root/CSharp/Ivy/IvyPPC/Ivy.cs
diff options
context:
space:
mode:
Diffstat (limited to 'CSharp/Ivy/IvyPPC/Ivy.cs')
-rw-r--r--CSharp/Ivy/IvyPPC/Ivy.cs25
1 files changed, 23 insertions, 2 deletions
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++)
{