This repository was archived by the owner on Apr 22, 2023. It is now read-only.
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
Send binary data via ChildProcess.send #5727
Closed
Description
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.
Metadata
Metadata
Assignees
Labels
No labels