You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
Is there a way to send binary data efficiently to a child process using (something as easy to use as) ChildProcess.send? send(buf) does not work as expected:
var cluster = require('cluster');
if (cluster.isWorker)
{
process.on('message', function messageHandler(msg)
{
console.log("msg: " + JSON.stringify(msg) +
" - type: " + typeof msg +
" - buf? " + Buffer.isBuffer(msg));
});
}
else
{
var buffer = new Buffer(2);
buffer[0] = 5;
buffer[1] = 88;
var worker = cluster.fork();
worker.on("online", function() { worker.send(buffer); });
}
The above will log
msg: [5,88] - type: object - buf? false
msg turns out to be a JSONified version of the original buffer.