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
29 When first activated with pcap_activate() or opened with
30 pcap_open_live() , a capture handle is not in ``non-blocking mode''; a
31 call to pcap_setnonblock() is required in order to put it into ``non-
32 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, -1 is returned and errbuf is filled in with an appropriate
38 error message.
39
40 errbuf is assumed to be able to hold at least PCAP_ERRBUF_SIZE chars.
41
43 pcap(3PCAP), pcap_loop(3PCAP), pcap_next_ex(3PCAP), pcap_geterr(3PCAP)
44
45
46
47 18 October 2014 PCAP_SETNONBLOCK(3PCAP)