I have 2 software componnects I'd like to make talk to each other,
The conversations I'd like to have are pretty simple,
or
Is there any painless way to pass messages between the 2?
My theoretical idea currently is something along these lines:
Is it terribly inefficient?
Is there actually thread support in node? (a short google didn't bring up any concrete results)
Basically you are in the right direction, you need some kind of inter-process-communication. It really depends how complex your IPC is. If it is just about some calling of methods and sharing simple (i.e. integer, strings) data between methods, you could live with unix sockets, that are fairly easy to implement and are supported by nodejs natively and are pretty easy to use from C as well (because the needed headers are almost always already available)
ZeroMQ gives you transport abstraction (allowing for IPC or true network-based transports) and a lot of bindings for even obscure languages. The provided examples for C and Node should get you going in no time. However you need the corresponding headers and libraries; that most likely need to be build first.
If the data that you are going to exchange between your programs is going to be more complex (read structs or arrays, nested objects), then you will need some real RPC implementation. There are a bunch of RPC implementations out there; feature-wise Apache Thrift looked very promising to me, although in the end I could not get the thrift compiler being build in a reasonable time.
So in the end, for me, having a rather similar use case, I ended up with ZeroMQ for the transport abstraction and on top of that using JSON-RPC as RPC mechanism. JSON-RPC is pretty native for nodejs and for C I used https://github.com/pijyoi/jsonrpc , that builds on ZeroMQ and Jansson. The documentation is non-existent but if you come that far, you shouldn't be afraid.
Performance-wise I don't think that this is going to be a problem; your use case does not sound, like you have a lot of requests in a short time. As ZeroMQ also offers traditional IPC as a transport, you could also use that to improve performance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With