1

I'm developing a lightweight framework to work as a coordinator in a Robotics competition I compete.

My idea, is to have agnostic programs about the whole, just with inputs that might triggers outputs. I then, connect those outputs to inputs, and can have different behaviours with the same modules, without hard work.

I'm planning on doing this with Node.js and WebKit, to allow a nice UI for modifying the process. However, each "module" might not really be a code wrapped in some javascript class-like function, it might be a real Thread, running maybe some C++ native code (without Node.js), or even a Python program.

What I'm facing now, is a fast way, and also generic, to exchange data among processes. I have read about it, but haven't got to any conclusions...

Here are the 3 methods I found out:

  1. Local Socket: Uses the localhost to dispatch a broadcast to a port
  2. Unix Socket: Maybe more efficient than the above (but using filesystem?)
  3. Stdin/Out communication: When a process is launched by Node.js, binding the stdin and stdout can be used to communicate between the program.

So, I have those 3 ways of doing it, what should I use mostly? I need things to communicate REALLY fast (data might go through 5 different processes, and I need that not to exceed 2ms)

Ivan Seidel
  • 2,394
  • 5
  • 32
  • 49
  • 1
    "best" can really only be discussed in any sort of non-opinion way if you set up some sort of measurable criteria for what you mean by best. Is performance your most important criteria so you're really just asking for the fastest way to communicate among processes on the same computer? – jfriend00 Jan 16 '16 at 23:36
  • 2
    See [Performance: TCP loopback connection vs Unix Domain Socket](http://stackoverflow.com/questions/14973942/performance-tcp-loopback-connection-vs-unix-domain-socket). It looks like a Unix Domain Socket wins over TCP loopback. Same conclusion here: [Performance Analysis of Various Mechanisms for Inter-process Communication](http://osnet.cs.binghamton.edu/publications/TR-20070820.pdf). – jfriend00 Jan 16 '16 at 23:38
  • I don't know if it applies to your problem or if you already looked into it but you can have real threads in nodejs: https://github.com/xk/node-threads-a-gogo The threads can talk with each other through events. – Shanoor Jan 17 '16 at 04:53

0 Answers0