通过电子/节点js中的tcp发送数据

时间:2018-10-04 10:51:37

标签: javascript c# node.js tcp electron

我想在ElectronJS中运行此C#代码,我如何做到这一点?

                    IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(_ClientInfo.IpAddress), 4446);
                client = new TcpClient();
                client.Connect(serverEndPoint);

                NetworkStream clientStream = client.GetStream();

                UTF8Encoding encoder = new UTF8Encoding();
                byte[] buffer = encoder.GetBytes(Command);

                clientStream.Write(buffer, 0, buffer.Length);

                clientStream.Flush();
                client.Close();
                client = null;

我尝试了这个,但是没有用。

                client.connect(4446, xxx.xxx.xx.xxx, function() {

                client.write(new TextEncoder().encode('blabla')); //write as Bytes
            });

0 个答案:

没有答案