I've been using the nonblocking IO in the -current libpcap tree with a great
deal of success.

pd = pcap_open_live(...);
pcap_setnonblock(pd, 1, errstr);
...
while(1) {
pcap_dispatch(pd, 1, mycallback, udata);
process_packet();
do_other_stuff();
...
}

You get the idea.

-m



On Tue, Jan 08, 2002 at 12:39:21PM +0200, Marco Slaviero wrote:
> Hi all
> 
> The app I'm busy with has the common situation of polling for user input,
> and waiting for packets from libpcap. I've been through the archives, and the
> select() was removed from pcap-linux.c with good reason.
> [http://www.tcpdump.org/lists/workers/2000/msg01674.html]
> 
> However, according to Guy Harris, select()/poll() it still the best method to
> accomplish the test for user input/packets.
> [http://www.tcpdump.org/lists/workers/2001/12/msg00087.html]
> 
> How about adding a pcap_is_packet_waiting() which will perform the test
> for you. The app would call pcap_dispatch() only  if
> pcap_is_packet_waiting() returns true, and the app can get on with other
> things on false.
> Arguments could be a pcap_t struct, and perhaps a timeout in
> microsecs. It seems that a select()/poll() based test would work on most
> systems, so surely this provides a platform-independent way to test?
> 
> I'm an "inexperienced" c and libpcap programmer, so feel free to shoot this
> down in descriptive flames.
> 
> Regards
> Marco Slaviero
> 
> PS. Thanks to all the libpcap authors for an excellent product.
> 
> -
> This is the TCPDUMP workers list. It is archived at
> http://www.tcpdump.org/lists/workers/index.html
> To unsubscribe use mailto:[EMAIL PROTECTED]?body=unsubscribe

-- 
As part of Mr. Lee's good neighbor policy, all Rat Things are programmed 
never to break the sound barrier in a populated area.  But Fido's in too 
much of a hurry to worry about the good neighbor policy.  Jack the sound 
barrier.  Bring the noise.  - Snowcrash
-
This is the TCPDUMP workers list. It is archived at
http://www.tcpdump.org/lists/workers/index.html
To unsubscribe use mailto:[EMAIL PROTECTED]?body=unsubscribe

Reply via email to