/// <summary> /// Start the server with the command-line arguments /// </summary> /// <param name="args"></param> /// <returns></returns> private static bool StartServer(string[] args) { // Get the configuration from the command-line arguments Config config = new Config(); if(!config.Parse(args)) return false; // Create an instance of the server and start it with the configuration Server server = new Server(); return server.Start(config); }
/// <summary> /// Start the server (both TCP socket and name pipe) /// </summary> /// <param name="config">Configuration of this instance</param> /// <returns>Return true if the server did start, false otherwise</returns> public bool Start(Config config) { try { // Create an instance of the logger logger_ = new Logger(config.LogLevel); // Record the name of the pipe, we may need it later to restart the pipe pipeName_ = config.Pipe; // First, start the named pipe StartPipe(); // Then, start the TCP socket StartSocket(config.Port); } catch(SocketException e) { // A socket error, display it logger_.Log(Level.Error, e.Message); // and stop the application there return false; } catch(IOException e) { // A I/O (probably pipe) error, display it logger_.Log(Level.Error, e.Message); // and stop the application there return false; } // The server did start return true; }