示例#1
0
 static void Main(string[] args)
 {
     ushort port = 8081;
     WebServer ws = new WebServer(port);
     ws.Start();
     ws.Start();
 }
示例#2
0
        static void Main(string[] args)
        {
            ushort    port = 8081;
            WebServer ws   = new WebServer(port);

            ws.Start();
            ws.Start();
        }
示例#3
0
        public void StartTest_SecondCall()
        {
            ushort port = 0;
            WebServer ws = new WebServer(port);

            ws.Start();
            var result = ws.Start();
            Assert.AreEqual("Already started!", result);
        }
示例#4
0
        public void StartTest_FirstCall()
        {
            ushort port = 0;
            WebServer ws = new WebServer(port);

            var result = ws.Start();
            Assert.AreEqual("Started...",result);
        }
示例#5
0
 static void Main(string[] args)
 {
     ushort port = 8081;
     WebServer ws = new WebServer(port);
     ws.Start();
     //while (true)
     //{
     //    var command = Console.ReadLine();
     //    if (command == "exit")
     //        ws.Stop();
     //}
 }
示例#6
0
        static void Main(string[] args)
        {
            ushort    port = 8081;
            WebServer ws   = new WebServer(port);

            ws.Start();
            //while (true)
            //{
            //    var command = Console.ReadLine();
            //    if (command == "exit")
            //        ws.Stop();
            //}
        }
示例#7
0
        static void Main(string[] args)
        {
            ushort port = 8081;
            if (args.Length != 0)
            {
                ushort paramPort;
                if (UInt16.TryParse(args[0], out paramPort))
                {
                    port = paramPort;
                }
            }
            else
            {
                string confPort = System.Configuration.ConfigurationManager.AppSettings["port"];
                if (confPort != null)
                {
                    UInt16.TryParse(confPort, out port);
                }
                else
                {
                    Console.WriteLine("{0}", port);
                }
            }
            bool isAvailable = true;

            IPGlobalProperties ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties();
            TcpConnectionInformation[] tcpConnArray = ipGlobalProperties.GetActiveTcpConnections();

            foreach (TcpConnectionInformation tcpi in tcpConnArray)
            {
                if (tcpi.LocalEndPoint.Port == port)
                {
                    isAvailable = false;
                    break;
                }
            }

            IPEndPoint[] listeningConnArray = ipGlobalProperties.GetActiveTcpListeners();
            foreach (IPEndPoint conn in listeningConnArray)
            {
                if (conn.Port == port)
                {
                    isAvailable = false;
                    break;
                }
            }

            if (isAvailable)
            {
                WebServer ws = new WebServer(port);
                ws.Start();
            }
            else
            {
                Console.WriteLine("Error! The requsted port is already in use.");
            }
            
            //while (true)
            //{
            //    var command = Console.ReadLine();
            //    if (command == "exit")
            //        ws.Stop();
            //}
            
        }
示例#8
0
 static void Main(string[] args)
 {
     WebServer ws = new WebServer();
     ws.Start();
 }
示例#9
0
        static void Main(string[] args)
        {
            WebServer ws = new WebServer();

            ws.Start();
        }