1 .\" Copyright (c) 1994, 1996, 1997
2 .\" The Regents of the University of California. All rights reserved.
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.
20 .TH PCAP_GET_REQUIRED_SELECT_TIMEOUT 3PCAP "29 January 2020"
22 pcap_get_required_select_timeout \- get a timeout to be used when doing
23 select() for a live capture
27 #include <pcap/pcap.h>
31 const struct timeval *pcap_get_required_select_timeout(pcap_t *p);
35 .BR pcap_get_required_select_timeout ()
36 returns, on UNIX, a pointer to a
38 containing a value that must be used as the minimum timeout in
46 if there is no such timeout.
49 value is returned, it must be used regardless of whether
50 .BR pcap_get_selectable_fd (3PCAP)
53 for any descriptor on which those calls are being done.
54 .BR pcap_get_required_select_timeout ()
55 should be called for all
63 and any timeouts used for those calls should be updated as appropriate
64 given the new value of the timeout.
70 filter per selectable descriptor can be used, rather than using the
75 event for a particular selectable descriptor signals an event,
77 should be called for the corresponding
81 .BR timerfd_create (2),
82 one timer object created by
84 per selectable descriptor can be used, rather than using the timeout
88 timer object for a particular selectable descriptor signals an event,
90 should be called for the corresponding
93 Otherwise, a timeout value no larger than
94 the smallest of all timeouts returned by
95 .BR \%pcap_get_required_select_timeout ()
96 for devices from which packets will be captured and any other timeouts
97 to be used in the call should be used as the timeout for the call, and,
98 when the call returns,
100 should be called for all
104 timeout was returned, regardless of whether it's indicated as having
105 anything to read from it or not.
109 timeout must be put in non-blocking mode with
110 .BR pcap_setnonblock (3PCAP).
112 Note that a device on which a read can be done without blocking may,
113 on some platforms, not have any packets to read if the packet buffer
114 timeout has expired. A call to
117 .BR pcap_next_ex (3PCAP)
118 will return 0 in this case, but will not block.
120 .BR pcap_get_required_select_timeout ()
121 is not available on Windows.
125 is returned if the timeout is required; otherwise
128 .SH BACKWARD COMPATIBILITY
129 This function became available in libpcap release 1.9.0. In previous
136 cannot be used on any capture source for which
137 .BR pcap_get_selectable_fd ()
140 In libpcap release 1.10.0 and later, the timeout value can change from
142 .BR pcap_get_required_select_timeout ()
143 must be called before each call to
149 and the new value must be used to calculate timeouts for the call. Code
150 that does that will also work with libpcap 1.9.x releases, so code
152 .BR pcap_get_required_select_timeout ()
153 should be changed to call it for each call to
159 even if the code must also work with libpcap 1.9.x.
162 .BR pcap_get_selectable_fd (3PCAP),