blob: bc33e5d3a7916e325a95fde1b6153a28cf147d94 [file] [log] [blame]
Haibo Huang165065a2018-07-23 17:26:52 -07001.\" 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_GET_REQUIRED_SELECT_TIMEOUT 3PCAP "20 January 2018"
21.SH NAME
22pcap_get_required_select_timeout \- get a file descriptor on which a
23select() can be done for a live capture
24.SH SYNOPSIS
25.nf
26.ft B
27#include <pcap/pcap.h>
28.ft
29.LP
30.ft B
31struct timeval *pcap_get_required_select_timeout(pcap_t *p);
32.ft
33.fi
34.SH DESCRIPTION
35.B pcap_get_required_select_timeout()
36returns, on UNIX, a pointer to a
37.B struct timeval
38containing a value that must be used as the minimum timeout in
39.BR select() ,
40.BR poll() ,
41.BR epoll_wait() ,
42and
43.B kevent()
44calls if
45.B pcap_get_selectable_fd()
46returns \-1.
47.PP
48The timeout that should be used in those calls must be no larger than
49the smallest of all timeouts returned by
50.B pcap_get_required_select_timeout()
51for devices from which packets will be captured.
52.PP
53The device for which
54.B pcap_get_selectable_fd()
55returned \-1 must be put in non-blocking mode with
56.BR pcap_setnonblock() ,
57and an attempt must always be made to read packets from the device
58when the
59.BR select() ,
60.BR poll() ,
61.BR epoll_wait() ,
62or
63.B kevent()
64call returns.
65.PP
66Note that a device on which a read can be done without blocking may,
67on some platforms, not have any packets to read if the packet buffer
68timeout has expired. A call to
69.B pcap_dispatch()
70or
71.B pcap_next_ex()
72will return 0 in this case, but will not block.
73.PP
74.B pcap_get_required_select_timeout()
75is not available on Windows.
76.SH RETURN VALUE
77A pointer to a
78.B struct timeval
79is returned if the timeout is required; otherwise
80.B NULL
81is returned.
82.SH SEE ALSO
83pcap(3PCAP), pcap_get_selectable_fd(3PCAP), select(2), poll(2),
84epoll_wait(2), kqueue(2)