예제 #1
0
        public Server(string ip, int port)
        {
            _tcpServer  = new TcpListener(IPAddress.Parse(ip), port);
            _infoWriter = InfoWriter.GetInstance();
            _tcpClients = new List <TcpClient>();

            _infoWriter.Write(InfoType.Info, string.Concat("IP: ", ip, " Port: ", port));
        }
        public static void Main()
        {
            try
            {
                Console.Title = "ServerApplication";

                SetConsoleCtrlHandler(Handler, true);

                var appSettings = ConfigurationManager.AppSettings;
                var ip          = appSettings.Get("IP");
                var port        = int.Parse(appSettings.Get("Port"));

                _server = new Server(ip, port);
                _server.TryDoRun();
            }
            catch (Exception e)
            {
                InfoWriter.GetInstance().Write(InfoType.Error, string.Format("Exception: {0}", e));
            }
        }