/// <summary> /// Method to stop run of the server connecting clients /// </summary> public void Stop() { this.run = false; IPAddress ipAddress = null; if (Dns.Resolve(Dns.GetHostName()).AddressList.Length > 1) { ipAddress = Dns.Resolve(Dns.GetHostName()).AddressList[1]; } else { ipAddress = Dns.Resolve(Dns.GetHostName()).AddressList[0]; } if (this.waitiForTwoConnection) { this.toClose = 2; TCPIPconnectorClient tmp = new TCPIPconnectorClient(this.port, ipAddress); TCPIPconnectorClient tmp2 = new TCPIPconnectorClient(this.port, ipAddress); tmp.Connect(); tmp2.Connect(); tmp.Dispose(); tmp2.Dispose(); } if (this.waitingForOneConnection) { this.toClose = 1; TCPIPconnectorClient tmp = new TCPIPconnectorClient(this.port, ipAddress); tmp.Connect(); tmp.Dispose(); } Thread.Sleep(10); this.Dispose(); //Console.WriteLine("Server Stopped"); Logger.LogEvent("Stop", "Server Stopped"); }
public void Stop() { this.run = false; if (this.waitiForTwoConnection) { this.toClose = 2; TCPIPconnectorClient tmp = new TCPIPconnectorClient(this.port, (Dns.Resolve(Dns.GetHostName())).AddressList[0]); TCPIPconnectorClient tmp2 = new TCPIPconnectorClient(this.port, (Dns.Resolve(Dns.GetHostName())).AddressList[0]); tmp.Connect(); tmp2.Connect(); tmp.Dispose(); tmp2.Dispose(); } if (this.waitingForOneConnection) { this.toClose = 1; TCPIPconnectorClient tmp = new TCPIPconnectorClient(this.port, (Dns.Resolve(Dns.GetHostName())).AddressList[0]); tmp.Connect(); tmp.Dispose(); } this.Dispose(); Console.WriteLine("Server Stopped"); }