[Winpcap-users] How to exit pcap_loop?

Goran Štrok goran.strok at uni-mb.si
Wed May 30 10:21:19 GMT 2007


Thanks for help. I try to do this: with press on button I would like to stop capturing packets. I try with scanf() function inside of function pcap_next_ex(), but this function  (scanf) wait until you press any button. Any suggestion?
Thanks!
  

while((res = pcap_next_ex( adhandle, &header, &pkt_data)) >= 0){
		if(res == 0)
			/* Timeout elapsed */
			continue;
		/* convert the timestamp to readable format */
		local_tv_sec = header->ts.tv_sec;
		ltime=localtime(&local_tv_sec);
		strftime( timestr, sizeof timestr, "%H:%M:%S", ltime);
		
		printf("%s,%.6d len:%d\n", timestr, header->ts.tv_usec, header->len);
	}
	
	if(res == -1){
		printf("Error reading the packets: %s\n", pcap_geterr(adhandle));
		return -1;
	}



-----Original Message-----
From: winpcap-users-bounces at winpcap.org on behalf of Gianluca Varenni
Sent: pet 27.4.2007 23:31
To: winpcap-users at winpcap.org
Subject: Re: [Winpcap-users] How to exit pcap_loop?
 
How to exit pcap_loop?Goran,

use pcap_next_ex() instead of pcap_loop() to receive the packets. Please follow the sample Examples-pcap\pktdump_ex in the WinPcap developer's pack.

Have a nice day
GV
  ----- Original Message ----- 
  From: Goran Štrok 
  To: winpcap-users at winpcap.org 
  Sent: Thursday, April 26, 2007 1:39 AM
  Subject: [Winpcap-users] How to exit pcap_loop?




  I want to end pcap_loop when push any (or specific) button on keyboard. How is this possible? Any suggestion? I use:
  pcap_loop(handle, -1, got_packet, (unsigned char *)file4);


  and want to capture packets until one of button is pushed. Maybe any other function?

  Thanks




------------------------------------------------------------------------------


  _______________________________________________
  Winpcap-users mailing list
  Winpcap-users at winpcap.org
  https://www.winpcap.org/mailman/listinfo/winpcap-users

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 3551 bytes
Desc: not available
Url : http://www.winpcap.org/pipermail/winpcap-users/attachments/20070530/ecad922f/attachment.bin


More information about the Winpcap-users mailing list