static void Main(string[] args) { ushort port = 8081; WebServer ws = new WebServer(port); ws.Start(); ws.Start(); }
public void StartTest_SecondCall() { ushort port = 0; WebServer ws = new WebServer(port); ws.Start(); var result = ws.Start(); Assert.AreEqual("Already started!", result); }
public void StartTest_FirstCall() { ushort port = 0; WebServer ws = new WebServer(port); var result = ws.Start(); Assert.AreEqual("Started...",result); }
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(); //} }
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(); //} }
static void Main(string[] args) { WebServer ws = new WebServer(); ws.Start(); }