net.sourceforge.jpcap.capture
Class SyncPacketCapture

java.lang.Object
  extended bynet.sourceforge.jpcap.capture.PacketDispatcher
      extended bynet.sourceforge.jpcap.capture.PacketCaptureBase
          extended bynet.sourceforge.jpcap.capture.PacketCapture
              extended bynet.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.


Field Summary
 
Fields inherited from class net.sourceforge.jpcap.capture.PacketCapture
LIB_PCAP_WRAPPER
 
Fields inherited from class net.sourceforge.jpcap.capture.PacketCaptureBase
droppedCount, linkType, receivedCount
 
Fields inherited from interface net.sourceforge.jpcap.capture.PacketCaptureCapable
DEFAULT_SNAPLEN, DEFAULT_TIMEOUT
 
Constructor Summary
SyncPacketCapture()
           
 
Method Summary
 void capture(int pck_count)
          Capture packets.
 void close()
          Close the capture device.
protected  void syncCapture(int pck_count)
           
 
Methods inherited from class net.sourceforge.jpcap.capture.PacketCapture
capture, close, findDevice, getLinkLayerType, getLinkLayerType, getNetmask, getNetwork, getSnapshotLength, getSnapshotLength, getStatistics, lookupDevices, open, open, open, openOffline, openOffline, setFilter, setFilter
 
Methods inherited from class net.sourceforge.jpcap.capture.PacketCaptureBase
handlePacket
 
Methods inherited from class net.sourceforge.jpcap.capture.PacketDispatcher
addPacketListener, addRawPacketListener, dispatchPacket, dispatchRawPacket, removePacketListener, removeRawPacketListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sourceforge.jpcap.capture.PacketCaptureCapable
addPacketListener, addRawPacketListener, removePacketListener, removeRawPacketListener
 

Constructor Detail

SyncPacketCapture

public SyncPacketCapture()
Method Detail

syncCapture

protected void syncCapture(int pck_count)
                    throws CapturePacketException
Throws:
CapturePacketException

capture

public void capture(int pck_count)
             throws CapturePacketException
Description copied from interface: PacketCaptureCapable
Capture packets.

Specified by:
capture in interface PacketCaptureCapable
Overrides:
capture in class PacketCapture
Throws:
CapturePacketException

close

public void close()
Description copied from interface: PacketCaptureCapable
Close the capture device.

Specified by:
close in interface PacketCaptureCapable
Overrides:
close in class PacketCapture