private static void ListenForClients() { tcpListener.Start(); if (Database.GetSetting("EnableOpenFirewall", "YAMS") == "true") { Networking.OpenFirewallPort(Convert.ToInt32(YAMS.Database.GetSetting("TelnetPort", "YAMS")), "Telnet"); } if (Database.GetSetting("EnablePortForwarding", "YAMS") == "true") { Networking.OpenUPnP(Convert.ToInt32(YAMS.Database.GetSetting("TelnetPort", "YAMS")), "Telnet", YAMS.Database.GetSetting("YAMSListenIP", "YAMS")); } while (true && stoppingServer == false) { //blocks until a client has connected to the server TcpClient client = tcpListener.AcceptTcpClient(); //create a thread to handle communication //with connected client TelnetClient myClient = new TelnetClient(client); } }