4/30/12

TCExecutor v0.0.1 released

TCExecutor - Telnet Command Executor C# open source project is released in version 0.0.1

Thanks to TCExecutor you can add communication/configuration layer to your application in just four steps:

  1. Create TCExecutor object
  2. Define commands
  3. Hook up your code to commands events (TCExecutor is multithread/multiconection application remeber that your code must be threadsafe)
  4. Start TCExecutor listener.
Commands style:
>command1 subcommand1 ... subcommandN param1=X1 ... paramN=XN ARGV1...ARGVN



Features:
  • Adds network communication layer to your application
  • Supports multiple connections. For each connection separate session is established.
  • Commands can be defined at your application startup.
  • Each command has separate event to which you can connect to.
  • Each command has a short and long help string which helps end user to navigate through available options.
Next releases features:
  • Enable SSH connections to the TCExecutor.
  • Add simple user autentication. Login password.
Project in action


Project can be found here: https://bitbucket.org/chesti/tcexecutor/
You can clone code from git: git clone https://bitbucket.org/chesti/tcexecutor.git
Code example:

using TelentCommandExecutor;

class ProgramObject
{
   private TCExecutor executorSRV;

   public ProgramObject()
   {
      //create an executor
      executorSRV = new TCExecutor();
   
      //hook up some commands
      CmdExecutor e;
      e = executorSRV.AddCommand("set name");
      e.ExecutorEvent += new CmdExecutor.ExecutorHandler(Execute_SetName);
      e.HelpString = "set name n=name";
      e.ShortHelpString = "Dispalys your name";
      
      //listen to the any end point on port 9999
      System.Net.IPEndPoint endPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Any, 9999);
      //start executor
      executorSRV.StartServer(endPoint);

      Console.ReadKey();

      //stop executor and disconnect all users.
      executorSRV.StopServer();
   }
   
   //handle command event
   string Execute_SetName(Cmd command)
   {
      if (command.CmdParams.ContainsKey("n"))
      {
          return String.Format("Your name is: {0}", command.CmdParams["n"]);
      }
      else
      {
         return "Use n= parameter";
      }
   }
}


4 comments:

  1. How many threads is created per tcp/ip connection? Suppose I have 1000 simultaneous connections. Is that mean that 1000 threads will be created?

    ReplyDelete
    Replies
    1. Hi Hats.
      Thanks for your comment.
      Answer to your question is yes it will create 1000 threads.
      I wasn't designing this library to support so many connections; I was thinking of a few.

      In this case I've decided to limit the maximum number of connections and I'll think of slightly different arhitecture to support many incoming connections in future releases.

      What do you think about max 100 threads each supporting max 100 connections? (it will give 10 000 simultaneous connections on 100 threads)

      Delete
  2. It would be nice to have a number of worker threads configurable somehow.

    Thanks.

    ReplyDelete
    Replies
    1. Hi Hats,

      I've created an issue report for that:

      https://bitbucket.org/chesti/tcexecutor/issue/8/maximum-connections

      Thanks

      Delete