--- pcap-linux.c +++ pcap-linux.c @@ -1594,6 +1593,18 @@ } } + if (to_ms > 0) { + struct timeval timeout; + timeout.tv_sec = to_ms / 1000; + timeout.tv_usec = (to_ms * 1000) % 1000000; + if (setsockopt(sock_fd, SOL_SOCKET, SO_RCVTIMEO, + &timeout, sizeof(timeout)) == -1) { + snprintf(ebuf, PCAP_ERRBUF_SIZE, + "setsockopt: %s", pcap_strerror(errno)); + break; + }; + } + /* Save the socket FD in the pcap structure */ handle->fd = sock_fd;