On Thu, Jun 10, 2004 at 04:44:20PM -0700, [EMAIL PROTECTED] wrote:
> I am really having some troubles with running pthreads and winpcap together.  
> I am pretty rusty on my C so maybe it is just my stupidity, but I keep getting
> lockups and my program will not run.
> 
> Basically, what I am trying to do is start a thread that will send out some
> packets once every few seconds.  While this thread is going the main program
> calls the pcap_loop and is listening for certain replies.
> 
> Unfortunately, when I put the pthread_create call in the program and run it, 
> it just locks up on that call(ran it in gdb).  I comment out that line and 
> the listening part runs just fine.
> 
[snip]
> =============== test.c =================
> 
> #include <pcap.h>
> #include <remote-ext.h> 
> #include <pthread.h>
> 
> void *test(void *blah)
> {
>   int done=0;    
>   while(!done){
>      printf("Who: %s\n", (char *)blah);
>      sleep(5);
>   }
> }
> 
> int main(){
>     pcap_if_t *alldevs;
>     pcap_if_t *d;
>     int inum;
>     int i=0;
>     pcap_t *adhandle;
>     char errbuf[PCAP_ERRBUF_SIZE];
> 
>     pthread_t t1;
>     pthread_create(&t1, NULL,&test,(void *)"numero uno");
>     pthread_join(t1,NULL);

To join a thread means to wait for it to complete. Since nothing sets
done in test(), your thread won't complete, so this thread will sit
waiting here indefinitely. This has nothing to do with winpcap.

Hope that helps,
Ainsley.


==================================================================
 This is the WinPcap users list. It is archived at
 http://www.mail-archive.com/[EMAIL PROTECTED]/

 To unsubscribe use 
 mailto: [EMAIL PROTECTED]
==================================================================

Reply via email to