[Winpcap-users] PacketReceivePacket error?
Charlie Heitzig
cheitzig at gmail.com
Tue Jan 25 05:04:18 PST 2011
Bit of an update to my problem-- the computer was going to Sleep (Windows
Sleep mode).
Question for the group though-- it appears I can't just use my existing
connection to the NIC once WIndows has slept/woken up. Do I need to close
the connection and re-open completely?
--> C
On Sun, Jan 23, 2011 at 11:43 AM, Charlie Heitzig <cheitzig at gmail.com>wrote:
> Looking for some thoughts on trouble-shooting a problem. First though, I'm
> a bit of a newbie to Winpcap.
>
> For background, I have a C program that is failing with a
> PacketReceivePacket error under Cygwin on Windows 7 x64. To better
> illustrate the problem, I built a debug / test harness around one of the
> Winpcap code samples-- basic_dump_ex.c (full modified version attached).
>
> I modified the last bit of code to loop and re-run pcap_next_ex() after an
> error:
>
>> 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));
>> /* Try the next packet one more time */
>> if((res = pcap_next_ex( adhandle, &header, &pkt_data)) == -1)
>> printf("Second error reading the packets: %s\n", pcap_geterr(adhandle));
>> return -1;
>> }
>
>
> But res never again returns a non-negative number as far as I can tell
> (even if I loop endlessly, continuously trying to get another packet.
>
> So that's my question, I guess-- is any error recovery possible after
> receiving a PacketReceivePacket error? Any advice on what
> a PacketReceivePacket error means-- bad NIC, bad router, cosmic rays? If I
> kill the program and re-start immediately, everything runs again for
> somewhere between 2 and 36 hours or so.
>
> Any thoughts would be appreciated!
>
> Best,
>
> --> C
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winpcap.org/pipermail/winpcap-users/attachments/20110125/345dfaf0/attachment.html>
More information about the Winpcap-users
mailing list