[Winpcap-users] How to break the pcap_loop

Steighton_Haley at McAfee.com Steighton_Haley at McAfee.com
Fri May 11 16:38:58 GMT 2007


I would make the following suggestions:

1) pcap_loop is deprecated and discouraged from use.  I recommend you
use the pcap_next_ex() function.

2) Read the documentation. It clearly outlines the situations in which
pcap_loop() will exit.  Specifically, when an error occurs, or when
'count' packets are received)... your count is 0, which isn't addressed
in the docs, it says a -1 will cause the system to loop forever, or at
least until an error occurs).


> I am developing an MFC application which uses Winpcap to 
> capture packets.
> I am using pcap_loop as follows:
> 
> pcap_loop(adhandle, 0, 
> (pcap_handler)CCaptureThread::packet_handler, NULL);
> 
> and the packet handler function is something like:
> void CCaptureThread::packet_handler(u_char *param, const 
> struct pcap_pkthdr *header, const u_char *pkt_data) {
> 	//capture the packet..		
> }
> 
> How do i break out of this pcap_loop?
> even using break_loop() after pcap_loop doesn't seem to work.
> 
> Thanks and Regards,
> 
> Narahari Upadhya
> 
> _______________________________________________
> Winpcap-users mailing list
> Winpcap-users at winpcap.org
> https://www.winpcap.org/mailman/listinfo/winpcap-users
> 



More information about the Winpcap-users mailing list