[Winpcap-users] Correct Initialization for winpcap

matt jaffa mjaffa at gmail.com
Tue Mar 28 21:00:14 GMT 2006


Hi,

I was wondering if how I was first initially using winpcap is the correct
way of doing it.
So I am looking up all the devices then creating a thread for each device to
listen for packets on.
Does this code look right?  (Code is below).

Thanks,
Matt


pcap_if_t *alldevs;

pcap_if_t *d;

int i=0;

char errbuf[PCAP_ERRBUF_SIZE];



if(pcap_findalldevs(&alldevs, errbuf) == -1)    // This is where it hangs
when are program is a service

{

fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf);

return;

}

for(d=alldevs; d; d=d->next)

{

char *deviceName = new char[256];

sprintf(deviceName, "%s", d->name);

CreateThread(NULL, 0, &StartRoutine, deviceName, 0, NULL);     // Each of
these threads listen for packets on each device

}

pcap_freealldevs(alldevs);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20060328/df46abff/attachment.htm


More information about the Winpcap-users mailing list