我正在尝试从节点应用程序结束IPC流。我似乎无法弄清楚哪个字符代表了流的结尾,而且我的流永远也不会结束。
const net = require("net");
const server = net.createServer((stream) => {
console.log("Server: on connection");
stream.on("data", (buffer) => {
console.log("Got data:", buffer.toString());
stream.write("This message ends here ->.");
});
stream.on("end", () => {
console.log("Stream ended");
server.close();
});
});
server.listen("\\\\.\\pipe\\myPipe", () => {
console.log("Listening...");
});
我试图在邮件末尾添加一个空字符(\ u0000),并在接收端进行检查,但这有点不安全。有没有办法发送诸如流结束字符之类的东西?
谢谢!