PcapHandle.loop
int loop(int cnt, void delegate(const(pcap_pkthdr) * header, const(ubyte) * data) callback)Processes packets from a live capture or savefile using a callback.
The callback delegate is GC-rooted for the duration of the call so that closures are not collected while libpcap is invoking the callback. Exceptions thrown in the callback are caught, the loop is broken, and the exception is re-thrown after pcap_loop returns.
Parameters
cnt | Number of packets to process. -1 processes all packets in a buffer (dispatch) or all in a file (loop). |
callback | The delegate to call for each packet. |
Returns
The number of packets processed, 0 if EOF, -1 on error, -2 if breakLoop was called.