[Winpcap-users] Multiple use of pcap_open 
    Gianluca Varenni 
    gianluca.varenni at cacetech.com
       
    Mon Jun 25 18:03:24 GMT 2007
    
    
  
----- Original Message ----- 
From: <ceo at triplebit.com>
To: <winpcap-users at winpcap.org>
Sent: Wednesday, July 25, 2007 7:00 AM
Subject: [Winpcap-users] Multiple use of pcap_open
> Can I run "pcap_open" on the same
> interface card in my 2 distinct threads?
Yes.
> In one thread I'd like to sniff the interface card for incoming/outgoing
> packets, while on the other thread I'd like to send packets.
> If positive, is there any need for coordination between them?
>
No. You can call the pcap function on different pcap handles (pcap_t) from 
different threads i.e. each thread dealing with its own pcap_t handle 
without any synchronization. There's only one function that should be 
protected because it's not thread safe, pcap_compile().
If you are calling this function from multiple threads at the same time, 
please protect with some code like
EnterCriticalSection(&MyCriticalSection);
pcap_compile()
LeaveCriticalSection(&MyCriticalSection);
Remember to initialize the critical section at the beginning of your 
application.
Have a nice day
GV
> Regards
>
> I. Lesher
>
>
> _______________________________________________
> Winpcap-users mailing list
> Winpcap-users at winpcap.org
> https://www.winpcap.org/mailman/listinfo/winpcap-users 
    
    
More information about the Winpcap-users
mailing list