PCAP_SET_TIMEOUT(3PCAP)

✨ PCAP_SET_TIMEOUT(3PCAP) ✨

okay bestie, welcome to the 3PCAP section of the manual, and today's main character is pcap_set_timeout β€” she sets the packet buffer timeout for a capture handle that hasn't been activated yet. no cap. πŸŽ€


🌸 NAME 🌸

pcap_set_timeout β€” set the packet buffer timeout for a not-yet-activated capture handle πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <pcap/pcap.h>

int pcap_set_timeout(pcap_t *p, int to_ms);

✨ DESCRIPTION ✨

so here's the tea, bestie: pcap_set_timeout() sets the packet buffer timeout that's gonna be used on a capture handle when the handle is activated, and it sets it to to_ms, which is measured in units of milliseconds. ⏱️ (if you need the whole explanation of what a packet buffer timeout even is, go read pcap(3PCAP) β€” she explains it, iykyk.)

now for the part that's giving danger 🚨: the behavior if the timeout isn't specified is undefined. and so is the behavior if the timeout is set to zero or to a negative value. like, truly undefined, not in a cute way.

πŸ’€ so what do we do? we recommend always setting the timeout to a non-zero value β€” unless immediate mode is set, in which case the timeout has no effect at all. periodt. βœ‹

πŸ’– RETURN VALUE πŸ’–

pcap_set_timeout() returns 0 on success 🫢 β€” or PCAP_ERROR_ACTIVATED if you called it on a capture handle that has already been activated. like girl, she's already awake, you can't set her timeout anymore 😭


πŸ‘‘ SEE ALSO πŸ‘‘

  • pcap_create(3PCAP)
  • pcap_activate(3PCAP)
  • pcap_set_immediate_mode(3PCAP)

and that's the whole vibe, bestie β€” this page is from 6 December 2017, and it lives in the PCAP_SET_TIMEOUT(3PCAP) manual. go set a non-zero timeout and slay πŸ’…βœ¨πŸŒΈ

πŸ“¦ where this page comes from