public void setTuner(Tuner tu) { _tuner = tu; }
//The constructor which make the TcpListener start listening on the //given port. It also calls a Thread on the method StartListen(). public bool Start(Tuner tuner) { _tuner = tuner; if (tuner == null) return true; if (Debugger.IsAttached) { _apppath = "../../WebServer"; } IPHostEntry host; host = Dns.GetHostEntry(Dns.GetHostName()); foreach (IPAddress ip in host.AddressList) { if (ip.AddressFamily.ToString() == "InterNetwork") { _localAddr = ip; break; } } if (_localAddr == null) return true; StringBuilder log = new StringBuilder(); try { //start listing on the given port _myListener = new TcpListener(_localAddr, _port); _myListener.Start(); log.Append("\n IP: " + _localAddr.ToString()); log.Append("\nWeb Server Running... Press ^C to Stop..."); //start the thread which calls the method 'StartListen' _th = new Thread(new ThreadStart(StartListen)); _th.Start(); } catch (Exception e) { log.Append("\nAn Exception Occurred while Listening :" + e.ToString()); SetText(log.ToString()); return true; } SetText(log.ToString()); return false; }