Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/465.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何将消息从节点JS发送到C++;密码 我使用节点JS运行C++程序,C++程序将从Linux中的一个进程ID开始。现在我想用Node JS的消息,使用启动的进程ID发送到C++程序。_Javascript_C++_Node.js - Fatal编程技术网

Javascript 如何将消息从节点JS发送到C++;密码 我使用节点JS运行C++程序,C++程序将从Linux中的一个进程ID开始。现在我想用Node JS的消息,使用启动的进程ID发送到C++程序。

Javascript 如何将消息从节点JS发送到C++;密码 我使用节点JS运行C++程序,C++程序将从Linux中的一个进程ID开始。现在我想用Node JS的消息,使用启动的进程ID发送到C++程序。,javascript,c++,node.js,Javascript,C++,Node.js,下面是从Node JS 调用C++的代码示例 childout = cp.spawn('/home/build/eth/eth',['-i'], function(error, stdout, stderr){ console.log("stdout :: " +stdout); console.log("stderror :: " +stderr); console.log("error :: " +error); }); 上述代码是从C++开始的,具有进程ID。现在我需要

下面是从Node JS

调用C++的代码示例
childout = cp.spawn('/home/build/eth/eth',['-i'], function(error, stdout, stderr){
   console.log("stdout :: " +stdout);
   console.log("stderror :: " +stderr);
   console.log("error :: " +error);
});
<>上述代码是从C++开始的,具有进程ID。现在我需要用这个进程ID发送一个消息。
有谁能指导我如何完成这项任务吗?

您可以使用pid(两端)来命名命名管道或unix域套接字。您还可以使用子进程stdin/stdout(/stderr)与它进行对话。很多可能性。。。请仔细阅读,了解一些想法。仅使用PID可以做的唯一一件事就是发送UNIX信号,但除了使用几个不同的信号(例如,HUP、USR1、USR2)来表示不同的内容外,您不能在其中包含消息。为什么不直接使用
spawn.stdin.write