kaitoy / pcap4j

A Java library for capturing, crafting, and sending packets.

Home Page:https://www.pcap4j.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PcapHandle not Closed if no packets received. How to forceful close handle

pratmodi opened this issue · comments

We are implementing dumping by packetcount based on filter by port. The call to listener.gotPacket(handle.getNextPacketEx()) keeps on listening for packets. There's a readtimeout too, but the call is stuck at listener.gotPacket(handle.getNextPacketEx()). We have already tried putting handle.close() in various places like finally,etc but it never gets closed. If we are sending packet traffic manually through postman at given port, then the packets get dumped and handle & dumper both get closed and work fine. Please suggest how to close the handle when there is no traffic. Again, we have kept readtimeout of 20 seconds but that also doesnt work. Following is the code we have written -

                                              if (dumper.isOpen()) {
							listener.gotPacket(handle.getNextPacketEx());
						}