/// <summary> /// Setting up TcpListener and stuff /// </summary> /// <remarks>Documented by Dev10, 2008-08-07</remarks> public void Listen() { try { bool done = false; listener = new TcpListener(usedIpAddress, portNumber); listener.Start(); //Get the portnumber the tcp listener is using usedPortNum = ((IPEndPoint)listener.LocalEndpoint).Port; #if DEBUG && DEBUG_OUTPUT Debug.WriteLine("Listening On: IP: " + usedIpAddress + " Port: " + usedPortNum.ToString()); #endif IsReady = true; while (!done) { listener.Start(); //ToDo: Check why a restart is needed! if (listener.Pending()) { CsHTTPRequest newRequest = new CsHTTPRequest(listener.AcceptTcpClient(), this); Thread Thread = new Thread(new ThreadStart(newRequest.Process)); Thread.IsBackground = true; Thread.Name = "HTTP Request"; Thread.CurrentCulture = Thread.CurrentThread.CurrentCulture; Thread.CurrentUICulture = Thread.CurrentThread.CurrentUICulture; Thread.Start(); } else { System.Threading.Thread.Sleep(10); } } } catch (ObjectDisposedException) { } catch (Exception e) { if (!(e is ThreadAbortException)) { Trace.WriteLine("Listener Thread Exception was thrown: " + e.ToString()); } } }
/// <summary> /// Setting up TcpListener and stuff /// </summary> /// <remarks>Documented by Dev10, 2008-08-07</remarks> public void Listen() { try { bool done = false; listener = new TcpListener(usedIpAddress, portNumber); listener.Start(); //Get the portnumber the tcp listener is using usedPortNum = ((IPEndPoint)listener.LocalEndpoint).Port; #if DEBUG && DEBUG_OUTPUT Debug.WriteLine("Listening On: IP: " + usedIpAddress + " Port: " + usedPortNum.ToString()); #endif IsReady = true; while (!done) { listener.Start(); //ToDo: Check why a restart is needed! if (listener.Pending()) { CsHTTPRequest newRequest = new CsHTTPRequest(listener.AcceptTcpClient(), this); Thread Thread = new Thread(new ThreadStart(newRequest.Process)); Thread.IsBackground = true; Thread.Name = "HTTP Request"; Thread.CurrentCulture = Thread.CurrentThread.CurrentCulture; Thread.CurrentUICulture = Thread.CurrentThread.CurrentUICulture; Thread.Start(); } else System.Threading.Thread.Sleep(10); } } catch (ObjectDisposedException) { } catch (Exception e) { if (!(e is ThreadAbortException)) { Trace.WriteLine("Listener Thread Exception was thrown: " + e.ToString()); } } }