I created an IPC server, I will send message to the client during the entire program life cycle. When the client receives the message, it will process it, but will not send the message to the server.
// Server.js
let server = net.createServer(socket=> {
socket.setEncoding('utf-8');
socket.on('close', onClientDisconnectOrProcessExit);
socket.on('error', err => {});
socket.on("data", data => {});
// Call four times continuously
socket.write("hello 1");
socket.write("hello 2");
socket.write("hello 3");
socket.write("hello 4");
}).listen({path: FIFO_NAME});
// Client.js
let socket = new net.Socket();
socket.setEncoding('utf-8');
socket.connect(FIFO_NAME, () => {});
socket.on('data', data => {
// Why only trigger once here ?
console.log(data);
});
When I try other solutions, add cork() and unsork() around but got same result:
socket.cork();
socket.write("hello 1");
socket.uncork();
socket.cork();
socket.write("hello 2");
socket.uncork();
socket.cork();
socket.write("hello 3");
socket.uncork();
socket.cork();
socket.write("hello 4");
socket.uncork();
Why it's os ?