-1 is NOT a valid timeout argument to pcap_open_live()
on any platform.
0, as a timeout argument, may behave differently on different platforms, and is not recommended.
And pcap_next()
is not guaranteed to wait forever for a packet to arrive; it might return NULL if the timeout expires. If you want to capture at least one packet, try looping until pcap_null()
doesn't return NULL.