<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle">P {
MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
</style>
</head>
<body fPStyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">
<p>I think you need to watch for the power management messages and stop processing when its going to sleep, and then wait until it resumes.
</p>
<p><a href="http://msdn.microsoft.com/en-us/library/Aa373247">http://msdn.microsoft.com/en-us/library/Aa373247</a></p>
<div>
<p id=""> </p>
<div style="FONT-SIZE: 13px; FONT-FAMILY: Tahoma">
<p>Michael D. Black</p>
<p>Senior Scientist</p>
<p>NG Information Systems</p>
<p>Advanced Analytics Directorate</p>
<p> </p>
</div>
</div>
<div style="FONT-SIZE: 16px; COLOR: #000000; FONT-FAMILY: Times New Roman">
<hr tabindex="-1">
<div id="divRpF528992" style="DIRECTION: ltr"><font face="Tahoma" color="#000000" size="2"><b>From:</b> winpcap-users-bounces@winpcap.org [winpcap-users-bounces@winpcap.org] on behalf of Charlie Heitzig [cheitzig@gmail.com]<br>
<b>Sent:</b> Tuesday, January 25, 2011 7:04 AM<br>
<b>To:</b> winpcap-users@winpcap.org<br>
<b>Subject:</b> EXTERNAL:Re: [Winpcap-users] PacketReceivePacket error?<br>
</font><br>
</div>
<div></div>
<div>Bit of an update to my problem-- the computer was going to Sleep (Windows Sleep mode).
<div><br>
</div>
<div>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?</div>
<div><br>
</div>
<div>--> C<br>
<br>
<div class="gmail_quote">On Sun, Jan 23, 2011 at 11:43 AM, Charlie Heitzig <span dir="ltr">
<<a href="mailto:cheitzig@gmail.com" target="_blank">cheitzig@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
Looking for some thoughts on trouble-shooting a problem. First though, I'm a bit of a newbie to Winpcap.
<div><br>
</div>
<div>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).
<div><br>
</div>
<div>I modified the last bit of code to loop and re-run pcap_next_ex() after an error:</div>
<div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<span></span>while((res = pcap_next_ex( adhandle, &header, &pkt_data)) >= 0){<br>
<span><br>
</span><span></span>if(res == 0)<br>
<span></span>/* Timeout elapsed */<br>
<span></span>continue;<br>
<span><br>
</span><span></span>/* convert the timestamp to readable format */<br>
<span></span>local_tv_sec = header->ts.tv_sec;<br>
<span></span>ltime=localtime(&local_tv_sec);<br>
<span></span>strftime( timestr, sizeof timestr, "%H:%M:%S", ltime);<br>
<span><br>
</span><span></span>printf("%s,%.6d len:%d\n", timestr, header->ts.tv_usec, header->len);<br>
<span></span>}<br>
<span><br>
</span><span></span>if(res == -1){<br>
<span></span>printf("Error reading the packets: %s\n", pcap_geterr(adhandle));<br>
<span></span>/* Try the next packet one more time */<br>
<span></span>if((res = pcap_next_ex( adhandle, &header, &pkt_data)) == -1) printf("Second error reading the packets: %s\n", pcap_geterr(adhandle));<br>
<span></span>return -1;<br>
<span></span>}</blockquote>
</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>Any thoughts would be appreciated!</div>
<div><br>
</div>
<div>Best,</div>
<div><br>
</div>
<font color="#888888">
<div>--> C</div>
</font></div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</body>
</html>