1

I need help on implementing an interprocess communication mechanism between JavaScript and C++ code. Basically I need to make a bidirectional communication. So JavaScript should be able to send and receive message from C++ (Win 32) code and vice versa.

1
  • 2
    You will need to give some more info on what you want to do. How is the js to be executed in a browser, shell script, embedded interpreter? Are they on teh same machine, same network? Does it need to handle firewalls? Commented Apr 21, 2011 at 8:19

4 Answers 4

2

You should look at Google's V8 JavaScript runtime, which powers their Chrome browser, it is implemented in C++. JSON libraries will simplify de/serialization.

Sign up to request clarification or add additional context in comments.

Comments

1

Qt contains the QtScript module, which is a native C++ implementation of JavaScript. I've used this successfully to script a C++ application, with communication in both directions.

If you're curious, the code is part of my HP 15C simulator project.

Comments

1

If you have the option of using Qt, I strongly recommend it. It's comprehensive and well tested. QtScript module. QtScript is a superset of javascript. The implementation uses Webkit's javascript core.

Comments

0

I presume you are doing this on a Windows OS. Does any kind of IPC help or are you specific on anything? Try named pipes; or shared memory with a sync object; or try a common file system memory, such as a binary file with a sync object to access it (although this is not recommended but is sure an option). You may also create COM objects / ActiveX controls and access this from JavaScript (browser).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.