public void TcpHostMethod() { ///int result = 1; ///Console.WriteLine(result.ToString() + " from thread ID: " + AppDomain.GetCurrentThreadId().ToString()); ///HostListen = new TcpListener(9050); HostListen = new TcpListener(localAddr, port); HostListen.Start(); Console.WriteLine("TcpHostThread: In TcpHostMethod:" + localAddr.ToString() + " " + port.ToString()); Console.WriteLine("Waiting for clients..."); bExitthread = false; while (!bExitthread) { while (!HostListen.Pending() && !bExitthread) { Thread.Sleep(1000); Console.WriteLine("TcpHostThread: In HostListen Pending!!"); } ///Thread.Sleep(1500); Console.WriteLine("TcpHostThread: In TcpHostMethod!!"); if (!bExitthread) { Console.WriteLine("TcpHostThread: Client found!!"); newconnection = new ConnectionThread(); newconnection.threadListener = this.HostListen; newthread = new Thread(new ThreadStart(newconnection.HandleConnection)); newthread.Start(); } } Console.WriteLine("TcpHostThread: Quit TcpHostMethod!!"); if (bExitthread) { Console.WriteLine("TcpHostThread: Abort newthread!!"); newthread.Abort(); } }
public void TcpHostMethod() { ///int result = 1; ///Console.WriteLine(result.ToString() + " from thread ID: " + AppDomain.GetCurrentThreadId().ToString()); ///HostListen = new TcpListener(9050); HostListen = new TcpListener(localAddr, port); HostListen.Start(); Console.WriteLine("TcpHostThread: In TcpHostMethod:" + localAddr.ToString() + " " + port.ToString() ); Console.WriteLine("Waiting for clients..."); bExitthread = false; while (!bExitthread) { while (!HostListen.Pending() && !bExitthread) { Thread.Sleep(1000); Console.WriteLine("TcpHostThread: In HostListen Pending!!"); } ///Thread.Sleep(1500); Console.WriteLine("TcpHostThread: In TcpHostMethod!!"); if (!bExitthread) { Console.WriteLine("TcpHostThread: Client found!!"); newconnection = new ConnectionThread(); newconnection.threadListener = this.HostListen; newthread = new Thread(new ThreadStart(newconnection.HandleConnection)); newthread.Start(); } } Console.WriteLine("TcpHostThread: Quit TcpHostMethod!!"); if (bExitthread) { Console.WriteLine("TcpHostThread: Abort newthread!!"); newthread.Abort(); } }