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">cheitzig@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

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="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204, 204, 204);border-left-style:solid;padding-left:1ex">




<span style="white-space:pre-wrap">     </span>while((res = pcap_next_ex( adhandle, &header, &pkt_data)) >= 0){<br><span style="white-space:pre-wrap">           <br></span><span style="white-space:pre-wrap">              </span>if(res == 0)<br>




<span style="white-space:pre-wrap">                     </span>/* Timeout elapsed */<br><span style="white-space:pre-wrap">                 </span>continue;<br><span style="white-space:pre-wrap">             <br>
</span><span style="white-space:pre-wrap">                </span>/* convert the timestamp to readable format */<br><span style="white-space:pre-wrap">                </span>local_tv_sec = header->ts.tv_sec;<br>
<span style="white-space:pre-wrap">             </span>ltime=localtime(&local_tv_sec);<br><span style="white-space:pre-wrap">           </span>strftime( timestr, sizeof timestr, "%H:%M:%S", ltime);<br>
<span style="white-space:pre-wrap">             <br></span><span style="white-space:pre-wrap">              </span>printf("%s,%.6d len:%d\n", timestr, header->ts.tv_usec, header->len);<br><span style="white-space:pre-wrap"> </span>}<br>




<span style="white-space:pre-wrap">     <br></span><span style="white-space:pre-wrap">      </span>if(res == -1){<br><span style="white-space:pre-wrap">                </span>printf("Error reading the packets: %s\n", pcap_geterr(adhandle));<br>




<span style="white-space:pre-wrap">             </span>/* Try the next packet one more time */<br><span style="white-space:pre-wrap">               </span>if((res = pcap_next_ex( adhandle, &header, &pkt_data)) == -1) printf("Second error reading the packets: %s\n", pcap_geterr(adhandle));<br>




<span style="white-space:pre-wrap">             </span>return -1;<br><span style="white-space:pre-wrap">    </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>