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.
I am compiling with cygwin (gcc 3.3.1) on a windows 98 box. I have tried with both
the beta winpcap and v3 (both act the same).
I am pasting a stripped down program that demonstrates my problem:
=============== 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);
/* Retrieve the device list */
if (pcap_findalldevs(&alldevs, errbuf) == -1)
{
fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf);
exit(1);
}
/* Print the list */
for(d=alldevs; d; d=d->next)
{
printf("%d. %s", ++i, d->name);
if (d->description)
printf(" (%s)\n", d->description);
else
printf(" (No description available)\n");
}
if(i==0)
{
printf("\nNo interfaces found! Make sure WinPcap is installed.\n");
return -1;
}
int ptret;
return 0;
}
=================================
I compile with these:
gcc test.c -mno-cygwin -c -o test.o -I ../../include -DWPCAP
gcc -mno-cygwin -L ../../lib -o test.exe test.o -lwpcap -lpthread
Any ideas?? My brain damage??
Thanks,
Eric Testegen
==================================================================
This is the WinPcap users list. It is archived at
http://www.mail-archive.com/[EMAIL PROTECTED]/
To unsubscribe use
mailto: [EMAIL PROTECTED]
==================================================================