How to stop capture using winpcap?

/* start the capture */
pcap_loop(adhandle, 0, packet_handler, NULL);

The above start capture, but I did not find a way to stop the capture, except for exiting the program ...

+3
source share
1 answer

Call pcap_breakloop()in your pcap_handler(you named it packet_handlerin your example). Then the call pcap_loop()will return -2.

Alternatively, repeat the calls pcap_dispatch()until you finish, or specify a non-zero value countto process this number of packets before returning.

+4
source

Source: https://habr.com/ru/post/1744589/


All Articles