public void AcceptClientTest() { string BindIp = "127.0.0.1"; ushort BindPort = NetworkUtilities.GetAvailableTcpPort(); var TestServerHandler = new ServerHandler(BindIp, BindPort); TcpClient TestClient; new Thread(() => { TestServerHandler.IsAcceptingSocketEvent.WaitOne(); TestClient = new TcpClient(BindIp, BindPort); }).Start(); TestServerHandler.ListenStart(); TestServerHandler.AcceptClient(); TestServerHandler.ListenStop(); }