两台机器通信,使用一发一收的方式, 上位机上 用wrieshark 抓包 和 用自己的程序抓包( 也是调用 WinPcap 驱动, 使用一个线程死循环等待 ) 。 发现一个奇怪的问题:
上位机发一个包下去,下位机发的包能很快的被wrieshark 抓到,但是被自己的程序抓到 要延迟一会,大概是1S,
假如下位机持续发包的话,自己的程序得到的相邻包的时间很短。——wrieshark 也是用的WinPcap 驱动, 这就是说WinPcap能很快的抓到包,但是他把抓到的包送到上层的APP, 需要一段时间, 是不是这样呢? 还是我WinPcap 用错了?
read_timeout,: read timeout in milliseconds. The read timeout is used to arrange that the read not necessarily return immediately when a packet is seen, but that it waits for some amount of time to allow more packets to arrive and to read multiple packets from the OS kernel in one operation. Not all platforms support a read timeout; on platforms that don't, the read timeout is ignored.