我有发送消息然后得到回复的 RouterSocket,问题是 ReceiveReady 无限触发。
这里是我的代码:
using NetMQ;
using NetMQ.Sockets;
using System.Text;
RouterSocket router = new RouterSocket();
router.Connect("tcp://127.0.0.1:8976");
router.ReceiveReady += RouterSocket_ReceiveReady;
router.SendFrame(Encoding.ASCII.GetBytes("Hello"));
NetMQPoller poller = new NetMQPoller{router};
poller.Run();
void RouterSocket_ReceiveReady(object? sender, NetMQSocketEventArgs e)
{
var message = router.ReceiveMultipartMessage();
Console.WriteLine($"Received: {message}");
}
行
Console.WriteLine($"Received: {message}");
一次又一次地打印响应