Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
170 views
in Technique[技术] by (71.8m points)

c# - .net udplistener.receive在hyperv vm与主机上的行为不一致(.net udplistener.receive acting inconsistently on hyperv vm vs host)

I have a simple c# win forms app acting as a "collector" for syslog messages.

(我有一个简单的C#Win Forms应用程序,充当syslog消息的“收集器”。)

This is a snipit of the code in question.

(这是有关代码的伪装。)

This code "works fine" on a win7 and server 2019 machine in that the call to udplistener.receive blocks when there is nothing to receive (at least I thought that was how it was supposed to work ;) But on a win7 hyperv vm and a server 2016 hyperv vm it doesn't block?

(这段代码在win7和server 2019机器上运行良好,因为在没有接收内容的情况下,对udplistener.receive的调用会阻塞(至少我认为那是应该的工作方式;)但是在win7 hyperv vm和服务器2016 hyperv vm它不会阻止?)

It "receives" the same data infinitely.

(它无限地“接收”相同的数据。)

I'm thinking its not clearing the buffer, so I added the debug prints, sure enough the second debug print is zero on "working" systems, but indeed is non zero on the systems that don't block.

(我认为它没有清除缓冲区,因此我添加了调试打印,确保第二个调试打印在“正常”系统上为零,但在不阻塞的系统上确实为非零。)

I'm doing some more troubleshooting, not 100% sure its related to the VM's, wondering if others have seen similar?

(我正在做更多的故障排除,不是100%地确定其与VM有关,想知道其他人是否也看到了类似的故障?)

Is there a reason a VM would handle this differently?

(VM是否有不同的处理方式?)

MessageInfo("DEBUG: available before .Receive " + udpListener.Available.ToString());
bReceive = udpListener.Receive(ref anyIP);  
MessageInfo("DEBUG: available after .Receive " + udpListener.Available.ToString());

thanks ben

(谢谢本)

  ask by bbad translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...