Stop pcap?
- Dominant language
- Go
- Stars
- 6.8k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
Stupid question but how do I stop pcap?
If I set a timeout in pcap.OpenLive, ReadPacketData waits until the timeout (regardless of packets received) and then gives me only the first packet it captured. This seems weird and broken.
If I set pcap.BlockForever, ReadPacketData doesn't return until it receives a packet. If no packet arrives, it doesn't stop. I can empty the BPF in another thread but if there are no packets at all on the NIC, it doesn't stop.
Close() blocks until ReadPacketData returns.
The only thing I've found so far is if I intentionally send a matching packet out the interface, ReadPacketData will return it, subsequently allowing me to shut down pcap. Surely there's a better way?
In C I think I would pcap_breakloop() but that doesn't seem to be exposed in gopacket pcap?
Contributor guide
Assessment
This issue has not been assessed yet.