xref: /freebsd/contrib/libpcap/pcap_get_required_select_timeout.3pcap (revision ec0ea6efa1ad229d75c394c1a9b9cac33af2b1d3)
Copyright (c) 1994, 1996, 1997
The Regents of the University of California. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that: (1) source code distributions
retain the above copyright notice and this paragraph in its entirety, (2)
distributions including binary code include the above copyright notice and
this paragraph in its entirety in the documentation or other materials
provided with the distribution, and (3) all advertising materials mentioning
features or use of this software display the following acknowledgement:
``This product includes software developed by the University of California,
Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
the University nor the names of its contributors may be used to endorse
or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

PCAP_GET_REQUIRED_SELECT_TIMEOUT 3PCAP "25 July 2018"
NAME
pcap_get_required_select_timeout - get a file descriptor on which a select() can be done for a live capture
SYNOPSIS
#include <pcap/pcap.h>

struct timeval *pcap_get_required_select_timeout(pcap_t *p);

DESCRIPTION
pcap_get_required_select_timeout() returns, on UNIX, a pointer to a struct timeval containing a value that must be used as the minimum timeout in select(2) , poll(2) , epoll_wait(2) , and kevent() calls if pcap_get_selectable_fd(3PCAP) returns PCAP_ERROR .

The timeout that should be used in those calls must be no larger than the smallest of all timeouts returned by \%pcap_get_required_select_timeout() for devices from which packets will be captured.

The device for which pcap_get_selectable_fd() returned PCAP_ERROR must be put in non-blocking mode with pcap_setnonblock(3PCAP) , and an attempt must always be made to read packets from the device when the select() , poll() , epoll_wait() , or kevent() call returns.

Note that a device on which a read can be done without blocking may, on some platforms, not have any packets to read if the packet buffer timeout has expired. A call to pcap_dispatch(3PCAP) or pcap_next_ex(3PCAP) will return 0 in this case, but will not block.

pcap_get_required_select_timeout() is not available on Windows.

RETURN VALUE
A pointer to a struct timeval is returned if the timeout is required; otherwise NULL is returned.
BACKWARD COMPATIBILITY
This function became available in libpcap release 1.9.0. In previous releases, select() , poll() , epoll_wait() , and kevent() cannot be used on any capture source for which pcap_get_selectable_fd returns -1.
SEE ALSO
pcap(3PCAP), pcap_get_selectable_fd(3PCAP), select(2), poll(2), epoll_wait(2), kqueue(2)