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, PCAP_ERROR is returned and errbuf is filled in
22 with an appropriate error message; otherwise, 0 is returned. In ``non-
23 blocking'' mode, an attempt to read from the capture descriptor with
24 pcap_dispatch(3PCAP) will, if no packets are currently available to be
25 read, return 0 immediately rather than blocking waiting for packets to
26 arrive. pcap_loop(3PCAP) and pcap_next(3PCAP) will not work in ``non-
27 blocking'' mode.
28
29 When first activated with pcap_activate(3PCAP) or opened with
30 pcap_open_live(3PCAP) , a capture handle is not in ``non-blocking
31 mode''; a call to pcap_setnonblock() is required in order to put it
32 into ``non-blocking'' mode.
33
35 pcap_getnonblock() returns the current ``non-blocking'' state of the
36 capture descriptor; it always returns 0 on ``savefiles''. If there is
37 an error, PCAP_ERROR is returned and errbuf is filled in with an appro‐
38 priate error message.
39
40 errbuf is assumed to be able to hold at least PCAP_ERRBUF_SIZE chars.
41
43 pcap(3PCAP), pcap_next_ex(3PCAP), pcap_geterr(3PCAP)
44
45
46
47 25 July 2018 PCAP_SETNONBLOCK(3PCAP)