Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a high-level inter-process communications API that is implemented in both C++ and Javascript

I am working on app where I need to pass messages between a C++ application and a Javascript web app.

Certainly I could write sockets code myself in either language and I have done this in the past when necessary.

What I would really like is a higher-level message posting or message queueing API that does a lot of the work for me. Does anyone know of such an API?

I have looked at ICE, and it doesn't appear to have Javascript bindings. I have also looked at Boost message queue, but it only caters for the C++ side of things. If necessary I might roll my own Javascript bindings for either of these technologies.

UPDATE: Sorry should have mentioned this before, I want to run this in a browser.

To give a more complete story what I want is a simple browser-based app that is used to configure and display logging for a C++ application.

I know there are other ways of doing this, but I am specifically interested in a high-level library in both C++ and browser-based Javascript that builds a message queue ontop of the sockets API (if there isn't one then I might consider implementing it myself and writing up a code project article).

ALSO: I'm not bothered about portability in terms of the web browser. Eg if there is a high-level IPC Javascript library that only works in Chrome, I'll be happy with that.

like image 371
Ashley Davis Avatar asked May 02 '12 01:05

Ashley Davis


People also ask

Is the inter-process communication facility provided by Java?

The Java programming language provides a comprehensive set of multithreading programming techniques but currently lacks interprocess communication (IPC) facilities, other than slow socket-based communication mechanisms (which are intended primarily for distributed systems, not interprocess communication on a multicore ...

How 2 processes can communicate with each other?

There are two modes through which processes can communicate with each other – shared memory and message passing.

How do you do inter-process communication in Java?

There are many ways to do inter-process communication in Java, you can use Sockets, both TCP and UDP, you can use RMI, you can use web services, or you can use memory-mapped file.

What is Inter-process communication communication between two process?

Inter-process communication (IPC) is a mechanism that allows processes to communicate with each other and synchronize their actions. The communication between these processes can be seen as a method of co-operation between them. Processes can communicate with each other through both: Shared Memory.


2 Answers

With JavaScript I assume that you are running it in a browser? In this case your C++ application needs to provide a webserver and some kind of JSON based webservice that you can call. On the JavaScript side you just use AJAX to communicate with that webservice.

An alternative would be websockets which might be a little harder to implement on the C++ side though.

like image 99
Daff Avatar answered Sep 20 '22 13:09

Daff


To simply answer your question: No, there is no IPC implemented in ECMAscript out of the box.

But you actually answered you question already. If you try to communicate with Javascript that runs in a browser, you indeed should use (web-)sockets connections to pipe date in either direction. Of course you could write a simple HTTP server in C++, but I guess that is overkill and does not have the capabilitys of bi-directional sockets.

It's still some work to implement a web-socket connection in C++ from the scratch (the specs were in flux for a long time), but I guess there are some librarys out already.

If you're trying to communicate with node.js, this is an almost trivial task using real sockets/pipes.

like image 25
jAndy Avatar answered Sep 21 '22 13:09

jAndy