pcap_get_required_select_timeout.3pcap 2.8 KB

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