On Jun 24, 2006, at 10:50 PM, Richard Hansen wrote:

I have one thread that sits in pcap_loop() and another thread that calls pcap_breakloop() when it is time to shut down. My code works well on Windows (WinPcap 3.1).

Well, sort of. I suspect that pcap_breakloop() doesn't *immediately* break you out of the loop - it's probably delayed until a packet arrives *or* the timeout expires.

On Linux (libpcap 0.9.4, kernel 2.6.16) the pcap_loop() doesn't return after calling pcap_breakloop() until another packet arrives. Is this expected or proper behavior?

Expected, yes. Linux's packet capture mechanism doesn't have the timeouts that the WinPcap driver, BPF, etc. do.

How can I tell Linux to return from that readfrom() call that it's blocking on?

You *might* be able to do it with pthread_cancel(), although that will, ultimately, terminate the thread (unless a cleanup handler never returns).
This is the tcpdump-workers list.
Visit https://lists.sandelman.ca/ to unsubscribe.

Reply via email to