]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/libpcap/pcap_setnonblock.3pcap
MFC r313695, r313760, r314769, r314863, r314865, r316125
[FreeBSD/FreeBSD.git] / contrib / libpcap / pcap_setnonblock.3pcap
1 .\" Copyright (c) 1994, 1996, 1997
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that: (1) source code distributions
6 .\" retain the above copyright notice and this paragraph in its entirety, (2)
7 .\" distributions including binary code include the above copyright notice and
8 .\" this paragraph in its entirety in the documentation or other materials
9 .\" provided with the distribution, and (3) all advertising materials mentioning
10 .\" features or use of this software display the following acknowledgement:
11 .\" ``This product includes software developed by the University of California,
12 .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
13 .\" the University nor the names of its contributors may be used to endorse
14 .\" or promote products derived from this software without specific prior
15 .\" written permission.
16 .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
17 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
18 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 .\"
20 .TH PCAP_SETNONBLOCK 3PCAP "18 October 2014"
21 .SH NAME
22 pcap_setnonblock, pcap_getnonblock \- set or get the state of
23 non-blocking mode on a capture device
24 .SH SYNOPSIS
25 .nf
26 .ft B
27 #include <pcap/pcap.h>
28 .ft
29 .LP
30 .nf
31 .ft B
32 char errbuf[PCAP_ERRBUF_SIZE];
33 .ft
34 .LP
35 .ft B
36 int pcap_setnonblock(pcap_t *p, int nonblock, char *errbuf);
37 int pcap_getnonblock(pcap_t *p, char *errbuf);
38 .ft
39 .fi
40 .SH DESCRIPTION
41 .B pcap_setnonblock()
42 puts a capture handle into ``non-blocking'' mode, or takes it out
43 of ``non-blocking'' mode, depending on whether the
44 .I nonblock
45 argument is non-zero or zero.  It has no effect on ``savefiles''.
46 If there is an error, \-1 is returned and
47 .I errbuf
48 is filled in with an appropriate error message; otherwise, 0 is
49 returned.
50 In
51 ``non-blocking'' mode, an attempt to read from the capture descriptor
52 with
53 .B pcap_dispatch()
54 will, if no packets are currently available to be read, return 0
55 immediately rather than blocking waiting for packets to arrive.
56 .B pcap_loop()
57 and
58 .B pcap_next()
59 will not work in ``non-blocking'' mode.
60 .PP
61 When first activated with
62 .B pcap_activate()
63 or opened with
64 .B pcap_open_live() ,
65 a capture handle is not in ``non-blocking mode''; a call to
66 .B pcap_setnonblock()
67 is required in order to put it into ``non-blocking'' mode.
68 .SH RETURN VALUE
69 .B pcap_getnonblock()
70 returns the current ``non-blocking'' state of the capture descriptor; it
71 always returns 0 on ``savefiles''.
72 If there is an error, \-1 is returned and
73 .I errbuf
74 is filled in with an appropriate error message.
75 .PP
76 .I errbuf
77 is assumed to be able to hold at least
78 .B PCAP_ERRBUF_SIZE
79 chars.
80 .SH SEE ALSO
81 pcap(3PCAP), pcap_loop(3PCAP), pcap_next_ex(3PCAP), pcap_geterr(3PCAP)