httpinterpret
httpinterpret

Reputation: 6709

How do I stop the capture using winpcap?

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

The above starts the capture,but I don't find a way to stop the capture except exit the programe...

Upvotes: 3

Views: 1570

Answers (1)

Matt Joiner
Matt Joiner

Reputation: 118540

Call pcap_breakloop() in your pcap_handler (you've named it packet_handler in your example). The call to pcap_loop() will then return -2.

Alternatively, make repeated calls to pcap_dispatch() until you're done, or specify a nonzero value for count to handle that number of packets before returning.

Upvotes: 5

Related Questions