Basically, you are in the right direction, you need some kind of interprocess communication. It really depends on how complex your IPC is. If we are only talking about some method calls and sharing simple (i.e., Integer, string) data between methods, you can live with unix sockets that are pretty easy to implement and are supported by nodejs initially and pretty easy to use from C like ( because the right headers are almost always available)
ZeroMQ provides you with a transport abstraction (allowing IPC or real network transports) and many bindings for even obscure languages. The above examples for C and Node should help you as soon as possible. However, you need appropriate headers and libraries; which, most likely, will need to be created first.
If the data you are going to exchange between your programs will be more complex (read structures or arrays, nested objects), then you will need a real RPC implementation. There are many RPC implementations; The special Apache Thrift looked very promising for me, although in the end I couldn't get the thrift collector to build in a reasonable amount of time.
So, in the end, for me, having a pretty similar use case, I ended up in ZeroMQ for transport abstraction and, moreover, using JSON-RPC as an RPC mechanism. JSON-RPC is pretty popular for nodejs, and for C I used https://github.com/pijyoi/jsonrpc , which is based on ZeroMQ and Jansson. Documentation does not exist, but if you go this far, you should not be afraid.
In terms of performance, I do not think this will be a problem; your use case doesn't sound like you have a lot of queries in a short time. Since ZeroMQ also offers traditional IPC as a transport, you can also use it to improve performance.
source share