问题描述
我试图让SharpPcap统计工作,但OnPcapStatistics事件永远不会触发。
I am trying to get SharpPcap Statistics to work, but the OnPcapStatistics event never fires.
这里的code:<一href="http://sharppcap.git.sourceforge.net/git/gitweb.cgi?p=sharppcap/sharppcap;a=blob;f=Examples/Example11.Statistics/Example11.Statistics.cs;h=c677ac75e1727e011f333bf942bdf48e4d724142;hb=HEAD"相对=nofollow> SharpPcap例11:统计
code项目的文章: SharpPcap:统计
Code project article: SharpPcap: Statistics
有谁知道为什么吗?
推荐答案
您刚刚发现了一个bug!
You just found a bug!
WinPcapDevice是建立一个新的SendPacketArrivalEvent(),而不是覆盖它。修改PcapDevice.SendPacketArrivalEvent()是一个虚拟的WinPcapDevice.SendPacketArrivalEvent()是一个重写,现在正确的方法被调用。
WinPcapDevice was creating a new SendPacketArrivalEvent() instead of overriding it. Modified PcapDevice.SendPacketArrivalEvent() to be a virtual and WinPcapDevice.SendPacketArrivalEvent() to be an override and now the correct method is called.
的问题是,由于WinPcapDevice是建立覆盖它的PcapDevice被捕获的数据包的新方法,而不是与调用自身的SendPacketArrivalEvent()。这个实现不处理事件的统计数据,因为它们是特定于WinPcapDevices。
The issue was that because WinPcapDevice was creating a new method instead of overriding it that PcapDevice was capturing a packet and calling its own SendPacketArrivalEvent(). This implementation doesn't handle statistics events as they are specific to WinPcapDevices.
固定的问题,更新了集信息4.0.1并上传大会filedropper:
Fixed the issue, updated the assembly info to 4.0.1 and uploaded the assembly to filedropper:
http://www.filedropper.com/sharppcap
如果你可以尝试,看看它的工作原理,我会检查修复到Git和它一起出去SharpPcap的下一个版本。
If you could try that and see that it works I'll check the fix into git and it will go out with the next release of SharpPcap.
再次感谢错误报告。
克里斯
SharpPcap的作者
Author of SharpPcap
这篇关于SharpPcap OnPcapStatistics事件永远不会触发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!