I am writing code to create an online c++ compiler in node.js environment.Using spawn
function i created a child process which will compile the code and execute it and send the output back to the user.
But i need to send input to the running c++ program . I used child.stdin.write('data');
for sending data to child but i think cin
in the program is not receiving the input .
Please help me to send the input to the running c++ code.
Thanks.
Sending input data to child process in node.js
5.1k Views Asked by Sri Harsha At
2
You should probably use either cluster, or fork if you want to pass messages... if you do this, node will setup IPC for you to be able to communicate via process.send
Alternatively, you could use a pub/sub system for communication channels (Redis works well for this), this is also your best bet if you need communications across servers.
Below is an example of an older work script...