public static void runConsole(object o) { if (consoleWorker != null) { return; } if (!(o is DBServer)) { return; } consoleWorker = new DBServerWorker(); consoleWorker.srv = (DBServer)o; while (true) { String line = Console.ReadLine(); if (String.IsNullOrEmpty(line)) { continue; } //Console.WriteLine(line); <-- echo if (line.ToLower().Equals("quit") || line.ToLower().Equals("exit")) { //throw new Exception("BUG"); /* ALL TESTS LOOK OK */ Environment.Exit(0); } String hResult = consoleWorker.processCommand(line); Console.WriteLine("reply {0}", hResult); } }
public void start() { //serverSocket.Start(); Console.WriteLine("Server listening on {0}:{1}", ((System.Net.IPEndPoint)(serverSocket.LocalEndpoint)).Address, ((System.Net.IPEndPoint)(serverSocket.LocalEndpoint)).Port); new Thread(new ParameterizedThreadStart(DBServerWorker.runConsole)).Start(this); Console.WriteLine("DEBUG CONSOLE ENABLED"); while (true) { //serverSocket. TcpClient s = serverSocket.AcceptTcpClient(); DBServerWorker newSession = new DBServerWorker(s, this); Thread workerThread = new Thread(new ThreadStart(newSession.run)); workerThread.Start(); } }