1 .\" @(#) $Header: /tcpdump/master/libpcap/pcap_get_selectable_fd.3pcap,v 1.1 2008-04-05 20:19:42 guy Exp $
3 .\" Copyright (c) 1994, 1996, 1997
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that: (1) source code distributions
8 .\" retain the above copyright notice and this paragraph in its entirety, (2)
9 .\" distributions including binary code include the above copyright notice and
10 .\" this paragraph in its entirety in the documentation or other materials
11 .\" provided with the distribution, and (3) all advertising materials mentioning
12 .\" features or use of this software display the following acknowledgement:
13 .\" ``This product includes software developed by the University of California,
14 .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
15 .\" the University nor the names of its contributors may be used to endorse
16 .\" or promote products derived from this software without specific prior
17 .\" written permission.
18 .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
19 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
20 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 .TH PCAP_GET_SELECTABLE_FD 3PCAP "4 April 2008"
24 pcap_get_selectable_fd \- get a file descriptor on which a select() can
25 be done for a live capture
33 int pcap_get_selectable_fd(pcap_t *p);
37 .B pcap_get_selectable_fd()
38 returns, on UNIX, a file descriptor number for a file descriptor on
44 to wait for it to be possible to read packets without blocking, if such
45 a descriptor exists, or \-1, if no such descriptor exists. Some network
52 (for example, regular network devices on FreeBSD 4.3 and 4.4, and Endace
53 DAG devices), so \-1 is returned for those devices.
55 Note that on most versions of most BSDs (including Mac OS X)
59 do not work correctly on BPF devices;
60 .B pcap_get_selectable_fd()
61 will return a file descriptor on most of those versions (the exceptions
62 being FreeBSD 4.3 and 4.4), a simple
66 will not return even after a timeout specified in
68 expires. To work around this, an application that uses
72 to wait for packets to arrive must put the
74 in non-blocking mode, and must arrange that the
78 have a timeout less than or equal to the timeout specified in
79 .BR pcap_open_live() ,
80 and must try to read packets after that timeout expires, regardless of
85 indicated that the file descriptor for the
87 is ready to be read or not. (That workaround will not work in FreeBSD
88 4.3 and later; however, in FreeBSD 4.6 and later,
92 work correctly on BPF devices, so the workaround isn't necessary,
93 although it does no harm.)
97 doesn't work on character special files, including BPF devices, in Mac
98 OS X 10.4 and 10.5, so, while
100 can be used on the descriptor returned by
101 .BR pcap_get_selectable_fd() ,
103 cannot be used on it those versions of Mac OS X. Kqueues also don't
104 work on that descriptor.
106 .B pcap_get_selectable_fd()
107 is not available on Windows.
109 A selectable file descriptor is returned if one exists; otherwise, \-1