Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Pipes! and they aint for smoke'n

Pipes! and they aint for smoke'n

Scheduled Pinned Locked Moved C#
hardwarelearning
3 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mel Feik
    wrote on last edited by
    #1

    Having been kicked out of the basement yet again to develop a little something in the "higher" level code I'm muddling around in the dark and trying to look bright doing it. I need to create a service that will launch mulitple instances of an application (APP) and be able to have some interaction with each APP as well as the service itself (via a serperate application to be developed later - which will be mostly used to add/remove APPs). Just to get the blood flowing, and something started on my desktop, I came up with this little mess...

    Process[] p = new Process[portsAL.Count];
    NamedPipeServerStream[] pipeServer = new NamedPipeServerStream[portsAL.Count];
    for (int i = 0; i < portsAL.Count; i++)
    {
    p[i] = new Process();
    p[i].StartInfo.FileName = appPath;
    p[i].StartInfo.Arguments = portsAL[i].ToString();
    p[i].Start();
    pipeServer[i] = new NamedPipeServerStream("pipe" + portsAL[i].ToString(), PipeDirection.InOut);
    pipeServer[i].WaitForConnection();
    }

    While that actually works (put in a bit-o-code into APP and each instance reported in on its assigned pipe) I will be the first to agree [admit] its not very elegant and I suspect its going to lead to my doing alot more work than my inheritently lazy nature will appreciate. Also, it became clear rather abruptly just how cumbersome it was going to become if I went much farther along these lines. Soooo..... here I am humbly seeking the wisdom of my betters to give me a shove in the right direction.

    --------------------------------------------- Help... I'm embedded and I can't get out! If they don't get the basic research and learning skills down then they'll end up having a very hard life (Either that or they'll become managers) - Micheal P Butler

    R 1 Reply Last reply
    0
    • M Mel Feik

      Having been kicked out of the basement yet again to develop a little something in the "higher" level code I'm muddling around in the dark and trying to look bright doing it. I need to create a service that will launch mulitple instances of an application (APP) and be able to have some interaction with each APP as well as the service itself (via a serperate application to be developed later - which will be mostly used to add/remove APPs). Just to get the blood flowing, and something started on my desktop, I came up with this little mess...

      Process[] p = new Process[portsAL.Count];
      NamedPipeServerStream[] pipeServer = new NamedPipeServerStream[portsAL.Count];
      for (int i = 0; i < portsAL.Count; i++)
      {
      p[i] = new Process();
      p[i].StartInfo.FileName = appPath;
      p[i].StartInfo.Arguments = portsAL[i].ToString();
      p[i].Start();
      pipeServer[i] = new NamedPipeServerStream("pipe" + portsAL[i].ToString(), PipeDirection.InOut);
      pipeServer[i].WaitForConnection();
      }

      While that actually works (put in a bit-o-code into APP and each instance reported in on its assigned pipe) I will be the first to agree [admit] its not very elegant and I suspect its going to lead to my doing alot more work than my inheritently lazy nature will appreciate. Also, it became clear rather abruptly just how cumbersome it was going to become if I went much farther along these lines. Soooo..... here I am humbly seeking the wisdom of my betters to give me a shove in the right direction.

      --------------------------------------------- Help... I'm embedded and I can't get out! If they don't get the basic research and learning skills down then they'll end up having a very hard life (Either that or they'll become managers) - Micheal P Butler

      R Offline
      R Offline
      Rob Philpott
      wrote on last edited by
      #2

      What about sockets? Old fashioned maybe, but you know where you are with a socket. Good for remote management etc. too.

      Regards, Rob Philpott.

      M 1 Reply Last reply
      0
      • R Rob Philpott

        What about sockets? Old fashioned maybe, but you know where you are with a socket. Good for remote management etc. too.

        Regards, Rob Philpott.

        M Offline
        M Offline
        Mel Feik
        wrote on last edited by
        #3

        The APPs are actually socket listeners - and they are the "priority" of this project. For example, if I send a "kill" message via the pipe, the APP needs to be a finished state on its port before it will shut down to aid in preventing data loss. But with my current skills set, I suspect I would find myself in the same situation - using an array in the service to establish/handle each socket connection to the APPs if I went that route. And its the array that I'm looking at as being the cumbersome aspect of my service.

        --------------------------------------------- Help... I'm embedded and I can't get out! If they don't get the basic research and learning skills down then they'll end up having a very hard life (Either that or they'll become managers) - Micheal P Butler

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups