[Winpcap-users] Problem with threading

Avelino Martins martins_ajc at msn.com
Thu Apr 19 21:18:42 GMT 2007


Hello all, 
despite all the threads i readed about issues on threading problems, i couldn't get to a conclusion at the specific issue of the function 
pcap_findalldevs() hanging when called from a child thread, take the simple example:
 
#include <pcap.h>
#pragma comment(lib, "Wpcap.lib")
 
void GetINetDevice()
{
     pcap_if_t* alldevs;
     char errbuf[PCAP_ERRBUF_SIZE+1];
 
     /* Retrieve the device list */
     if(pcap_findalldevs(&alldevs, errbuf) == -1)
     {
          printf("Error in pcap_findalldevs: %s\n", errbuf);
          exit(1);
     }
     // Could not create thread
     MessageBox(NULL, "Sucess","",MB_OK);
 
     // Free the device list 
     pcap_freealldevs(alldevs);
}
 
 
int main()
{ 
     DWORD m_dwThreadID;
     HANDLE m_hThread;
     m_hThread = CreateThread(0,
                                             0,
                                             (LPTHREAD_START_ROUTINE)GetINetDevice,
                                             NULL,
                                             0,
                                             &m_dwThreadID);
     if(!m_hThread)
     {
          // Could not create thread
          MessageBox(NULL, "Thread error","",MB_OK);
     }
     return 0;
}
 
Is anyone able to tell me if the fact of the app hangs/exits on pcap_findalldevs(), is a known issue at winpcap, and if there is any workaround?
 
Best Regards
_________________________________________________________________
Veja mais. Partilhe mais. Experimente o Windows Live Messenger beta gratuitamente
http://ideas.live.com/programpage.aspx?versionId=0eccd94b-eb48-497c-8e60-c6313f7ebb73
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20070419/d60d9c04/attachment.htm


More information about the Winpcap-users mailing list