gpt4 book ai didi

angular - 如何使用 Electron 和 Angular 与NamedPipe连接

转载 作者:行者123 更新时间:2023-12-03 12:22:28 24 4
gpt4 key购买 nike

尝试在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')))
This is what I am getting in the console when printing client instance after net.connect(namedPipePath)

最佳答案

在您的实现中没有发现任何错误。我不确定您是否正在使用Socket编写代码,因为您没有在上面的代码段中共享该段代码。

尝试下面的代码以及您现有的代码,相信我,您的套接字会听你说:)

public write(buffer: Buffer): void {
if (this.client.destroyed) {
return;
}
this.client.write(buffer);
}

关于angular - 如何使用 Electron 和 Angular 与NamedPipe连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56856451/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com