场景:我可以使用以下代码通过 ZeroMQ (ØMQ) 将字符串类型的数据从 C# 发送到 Node.JS 应用程序:
C# 推送代码:
using (var context = new Context(1))
{
using (Socket client = context.Socket(SocketType.PUSH))
{
client.Connect("tcp://127.0.0.1:12345");
int i = 0;
while (true)
{
string request = i.ToString() + "_Hello_ ";
i++;
Console.WriteLine("Sending request..." + i.ToString());
client.Send(request, Encoding.Unicode);
// <== Here is the issues
string reply = client.Recv(Encoding.Unicode).ToString();
// <== Here is the issues
Console.WriteLine("Received reply :", reply);
}
}
}
Node.JS 拉取代码:
pull_socket.bindSync('tcp://127.0.0.1:12345')
pull_socket.on('message', function (data) {
i++;
console.log(i.toString() + 'received data:\n');
console.log(data.toString());
pull_socket.send('rcvd'); // <== Here is the issues
});
问题:在 C#reply
对象中将包含字符串"Not supported"
,但发送的数据将在 Node.js 中正确接收。
问题:谁能告诉我我做错了什么?请稍微说明一下这个问题。
高级感谢