Yeah I saw Bryan's reply, but adding those services (npf, nm) to my service's depnedons mutli-string value didn't produce any different results.<br><br>
<div><span class="gmail_quote">On 3/28/06, <b class="gmail_sendername">Guy Harris</b> <<a href="mailto:guy@alum.mit.edu">guy@alum.mit.edu</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><br>On Mar 28, 2006, at 1:00 PM, matt jaffa wrote:<br><br>> I was wondering if how I was first initially using winpcap is the
<br>> correct way of doing it.<br>> So I am looking up all the devices then creating a thread for each<br>> device to listen for packets on.<br>> Does this code look right?<br><br>Not entirely - see below.<br>
<br>> if(pcap_findalldevs(&alldevs, errbuf) == -1) // This is where it<br>> hangs when are program is a service<br><br>Did you see Bryan Kadzban's reply?<br><br>> char *deviceName = new char[256];<br>> sprintf(deviceName, "%s", d->name);
<br>This assumes that the device name fits in 256 characters. That's<br>probably true, so it's probably not causing problems in your code,<br>but, as a general programming practice, it's unsafe.<br><br>Also, the "sprintf" is overkill, as all you're doing is copying the
<br>string.<br><br> char *Devicename = strdup(d->name);<br><br>would suffice.</blockquote>
<div> </div>
<div> </div>
<div>I did have something similar to that way before, but I was noticing as I was passing the pointer to the thread the name of the device was being corrupted. I never did use the strdup call though, maybe that would solve that problem and can get rid of the set size of 256.
</div>
<div> </div>
<div>Thanks,</div>
<div>Matt</div><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">_______________________________________________<br>Winpcap-users mailing list<br><a href="mailto:Winpcap-users@winpcap.org">
Winpcap-users@winpcap.org</a><br><a href="https://www.winpcap.org/mailman/listinfo/winpcap-users">https://www.winpcap.org/mailman/listinfo/winpcap-users</a><br></blockquote></div><br>