UdpClient 接收直到第二次广播才返回
我觉得这真的很奇怪。尝试使用UdpClient同步接收广播消息,但广播完成却没有返回。直到后来的广播中我才收到消息。我认为框架内某个地方存在错误?
clientListener.BeginReceive(new AsyncCallback(RxBcastCallback), clientListener);
//this is passed as AsyncCall.AsyncState in the callback
.....
UdpClient udpListener = (UdpClient)AsyncCall.AsyncState;
IPEndPoint remoteEndPt = new IPEndPoint(IPAddress.Any, 0);
byte[] inBuffer = udpListener.Receive(ref remoteEndPt);
//does not return until subsequent broadcast
谢谢, 肯尼
I think this is really weird. Tried to use UdpClient to synchronously receive broadcast msg, but it does not return although the broadcast has completed. Only on subsequent broadcast did I get the message. I think there's a bug somewhere within the framework?
clientListener.BeginReceive(new AsyncCallback(RxBcastCallback), clientListener);
//this is passed as AsyncCall.AsyncState in the callback
.....
UdpClient udpListener = (UdpClient)AsyncCall.AsyncState;
IPEndPoint remoteEndPt = new IPEndPoint(IPAddress.Any, 0);
byte[] inBuffer = udpListener.Receive(ref remoteEndPt);
//does not return until subsequent broadcast
thanks,
Kenny
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的回调端点可能应该是:
Your callback endpoint should probably be: