net.sourceforge.jpcap.capture
Class SyncPacketCapture
java.lang.Object
|
+--net.sourceforge.jpcap.capture.PacketDispatcher
|
+--net.sourceforge.jpcap.capture.PacketCaptureBase
|
+--net.sourceforge.jpcap.capture.PacketCapture
|
+--net.sourceforge.jpcap.capture.SyncPacketCapture
- All Implemented Interfaces:
- PacketCaptureCapable, PacketDispatchCapable, net.sourceforge.jpcap.capture.PacketHandler
- public class SyncPacketCapture
- extends PacketCapture
This class adds to PacketCapture the ability to explicitly terminate
a capture session using close().
SyncPacketCapture utilizes libpcap's pcap_dispatch().
SyncPacketCapture inherits from the PacketCapture overriding its
open(), capture() and close() methods in a way to keep synchronized the
starting and the stopping phases of any capture() session . That
allows close() method call to be performed any time from everywhere.
Method Summary |
void |
capture(int pck_count)
Capture packets. |
void |
close()
Close cleans up after a packet capture session. |
protected void |
syncCapture(int pck_count)
|
Methods inherited from class net.sourceforge.jpcap.capture.PacketCapture |
findDevice, getLinkLayerType, getNetmask, getNetwork, getSnapshotLength, getStatistics, lookupDevices, open, open, openOffline, setFilter |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SyncPacketCapture
public SyncPacketCapture()
syncCapture
protected void syncCapture(int pck_count)
throws CapturePacketException
capture
public void capture(int pck_count)
throws CapturePacketException
- Description copied from interface:
PacketCaptureCapable
- Capture packets.
- Overrides:
capture
in class PacketCapture
- Following copied from interface:
net.sourceforge.jpcap.capture.PacketCaptureCapable
- Parameters:
count
- the number of packets to capture.
If count is negative, capture will block forever, unless an exception
is thrown.
close
public void close()
- Description copied from class:
PacketCapture
- Close cleans up after a packet capture session.
It does _not_ terminate a packet capture.
capture() does not return control until 'count' packets are captured.
If you are looking for a way to signal an end to a capture session
before a set number of packets are received, check out the class
SyncPacketCapture.
- Overrides:
close
in class PacketCapture