Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        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();
        }