[Winpcap-users] How to exit pcap_loop?
Gianluca Varenni
gianluca.varenni at cacetech.com
Wed May 30 15:31:58 GMT 2007
You can use kbhit() to test if a key was pressed.
Have a nice day
GV
----- Original Message -----
From: "Goran Štrok" <goran.strok at uni-mb.si>
To: <winpcap-users at winpcap.org>
Sent: Wednesday, May 30, 2007 3:21 AM
Subject: RE: [Winpcap-users] How to exit pcap_loop?
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
--------------------------------------------------------------------------------
> _______________________________________________
> 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