尝试在Angular Service中连接命名管道并在Electron中进行构建。
我试着net
插座类,但好像它不工作不得到console.log
的data
。
import * as net from 'net';
const client: net.Socket = net.connect(namedPipePath);
client.on("data", (d: Buffer) => console.log("connected", d.toString('utf8')));
client.on("error", (err) => console.error(err));
client.on("end", () => console.log('disconnected from server'));
我应该得到 console.log("connected", d.toString('utf8')))
在您的实现中没有发现任何错误。我不确定您是否正在使用中编写Socket
代码,因为您没有在上面的代码段中共享该段代码。
尝试下面的代码以及您现有的代码,相信我,您的套接字会听你说:)
public write(buffer: Buffer): void {
if (this.client.destroyed) {
return;
}
this.client.write(buffer);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句