- .NET API: fixed server side bug with connection indication handler

pull/6/head
Michael Zillgith 9 years ago
parent 5358ef28c3
commit e6b8e09e91

@ -779,11 +779,15 @@ namespace IEC61850
// } // }
//} //}
private InternalConnectionHandler internalConnectionHandler = null;
/// <summary>Start MMS server</summary> /// <summary>Start MMS server</summary>
public void Start(int tcpPort) public void Start(int tcpPort)
{ {
IedServer_setConnectionIndicationHandler (self, connectionIndicationHandler, IntPtr.Zero); if (internalConnectionHandler == null)
internalConnectionHandler = new InternalConnectionHandler (connectionIndicationHandler);
IedServer_setConnectionIndicationHandler (self, internalConnectionHandler, IntPtr.Zero);
IedServer_start(self, tcpPort); IedServer_start(self, tcpPort);
} }
@ -801,6 +805,7 @@ namespace IEC61850
public void Stop() public void Stop()
{ {
IedServer_stop(self); IedServer_stop(self);
internalConnectionHandler = null;
} }
/// <summary> /// <summary>
@ -811,6 +816,7 @@ namespace IEC61850
{ {
IedServer_destroy(self); IedServer_destroy(self);
self = IntPtr.Zero; self = IntPtr.Zero;
internalConnectionHandler = null;
} }
public bool IsRunning() public bool IsRunning()

@ -17,14 +17,19 @@ namespace example1
if (args.Length > 0) if (args.Length > 0)
hostname = args[0]; hostname = args[0];
else else
hostname = "10.0.2.2"; hostname = "127.0.0.1";
int port = 102;
if (args.Length > 1)
port = Int32.Parse(args [1]);
Console.WriteLine("Connect to " + hostname); Console.WriteLine("Connect to " + hostname);
try try
{ {
con.Connect(hostname, 102); con.Connect(hostname, port);
List<string> serverDirectory = con.GetServerDirectory(false); List<string> serverDirectory = con.GetServerDirectory(false);

@ -42,6 +42,8 @@ namespace server1
iedServer.Start (102); iedServer.Start (102);
Console.WriteLine ("Server started"); Console.WriteLine ("Server started");
GC.Collect ();
while (running) { while (running) {
Thread.Sleep (1); Thread.Sleep (1);
} }

Loading…
Cancel
Save