1PCAP_SETNONBLOCK(3PCAP) PCAP_SETNONBLOCK(3PCAP)
2
3
4
6 pcap_setnonblock, pcap_getnonblock - set or get the state of non-block‐
7 ing mode on a capture device
8
10 #include <pcap/pcap.h>
11
12 char errbuf[PCAP_ERRBUF_SIZE];
13
14 int pcap_setnonblock(pcap_t *p, int nonblock, char *errbuf);
15 int pcap_getnonblock(pcap_t *p, char *errbuf);
16
18 pcap_setnonblock() puts a capture handle into ``non-blocking'' mode, or
19 takes it out of ``non-blocking'' mode, depending on whether the non‐
20 block argument is non-zero or zero. It has no effect on ``savefiles''.
21 If there is an error, -1 is returned and errbuf is filled in with an
22 appropriate error message; otherwise, 0 is returned. In ``non-block‐
23 ing'' mode, an attempt to read from the capture descriptor with
24 pcap_dispatch() will, if no packets are currently available to be read,
25 return 0 immediately rather than blocking waiting for packets to
26 arrive. pcap_loop() and pcap_next() will not work in ``non-blocking''
27 mode.
28
30 pcap_getnonblock() returns the current ``non-blocking'' state of the
31 capture descriptor; it always returns 0 on ``savefiles''. If there is
32 an error, -1 is returned and errbuf is filled in with an appropriate
33 error message.
34
35 errbuf is assumed to be able to hold at least PCAP_ERRBUF_SIZE chars.
36
38 pcap(3PCAP), pcap_loop(3PCAP), pcap_next_ex(3PCAP), pcap_geterr(3PCAP)
39
40
41
42 5 April 2008 PCAP_SETNONBLOCK(3PCAP)