static void Main(string[] args) { var telnetServer = new TelnetServer(); if (!telnetServer.Setup(2002)) { Console.WriteLine("设置失败!"); Console.ReadKey(); return; } Console.WriteLine(); if (!telnetServer.Start()) { Console.WriteLine("启动失败!"); Console.ReadKey(); return; } Console.WriteLine("服务启动成功"); Console.ReadLine(); telnetServer.Stop(); Console.WriteLine("服务关闭!"); Console.ReadLine(); }
static void Main(string[] args) { Console.WriteLine("Press any key to start the server!"); Console.ReadKey(); Console.WriteLine(); var appServer = new TelnetServer(); var serverConfig = new ServerConfig { Port = 2012 //set the listening port }; //Setup the appServer if (!appServer.Setup(serverConfig)) { Console.WriteLine("Failed to setup!"); Console.ReadKey(); return; } Console.WriteLine(); //Try to start the appServer if (!appServer.Start()) { Console.WriteLine("Failed to start!"); Console.ReadKey(); return; } Console.WriteLine("The server started successfully, press key 'q' to stop it!"); while (Console.ReadKey().KeyChar != 'q') { Console.WriteLine(); continue; } Console.WriteLine(); //Stop the appServer appServer.Stop(); Console.WriteLine(); Console.WriteLine("The server was stopped!"); Console.ReadKey(); }
/// <summary> /// Initialize the server prompt and greeting, and start the server. /// </summary> private void InitializeTelnetServer() { //Set the prompt //Possibly this could contain the "timer" function of the GUI application this is a rewrite of _TelnetServer.Prompt = "Dictionariosaur"; //Do our pretty Ascii telnet greeter string tmpTelnetGreeting = ""; tmpTelnetGreeting = string.Concat(tmpTelnetGreeting, "MUTINATION\r\n"); tmpTelnetGreeting = string.Concat(tmpTelnetGreeting, "----------------------------------------------------| Scrabble Dictionary |----\r\n"); _TelnetServer.Greeting = tmpTelnetGreeting; _TelnetServer.Start(); }
static void Main(string[] args) { Console.WriteLine("Press any key to start the server!"); Console.ReadKey(); Console.WriteLine(); var appServer = new TelnetServer(); appServer.NewSessionConnected += AppServer_NewSessionConnected; appServer.NewRequestReceived += AppServer_NewRequestReceived; appServer.SessionClosed += AppServer_SessionClosed; //Setup the appServer if (!appServer.Setup(2012))//setup with listening port { Console.WriteLine("Failed to setup"); Console.ReadKey(); return; } Console.WriteLine(); //Try to start the appServer if (!appServer.Start()) { Console.WriteLine("Failed to start"); Console.ReadKey(); return; } Console.WriteLine("The server started successfully,press key 'q' to stop it!"); while (Console.ReadKey().KeyChar != 'q') { Console.WriteLine(); continue; } //Stop the appServer appServer.Stop(); Console.WriteLine("The server was stopped!"); Console.ReadKey(); }