SourceForge Jpcap

net.sourceforge.jpcap.capture
Class PacketInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by net.sourceforge.jpcap.capture.PacketInputStream
All Implemented Interfaces:
Closeable

public abstract class PacketInputStream
extends InputStream

PacketInputStream provides an easy way of reading packets from the network or a savefile without having to define and register PacketListeners.

Since:
2.0.0
Version:
$Revision: 1.1 $
Author:
Esmond Pitt
See Also:
PacketCapture.getInputStream()

Constructor Summary
protected PacketInputStream()
          Creates a new instance of PacketInputStream
 
Method Summary
abstract  void close()
           Closing the stream stops all the associated capture activities.
 int read()
          
 int read(byte[] buffer)
          
 int read(byte[] buffer, int offset, int length)
          
abstract  Packet readPacket()
          Read a Packet from the network or savefile, depending on how the stream was constructed.
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PacketInputStream

protected PacketInputStream()
Creates a new instance of PacketInputStream

Method Detail

close

public abstract void close()
                    throws IOException
Closing the stream stops all the associated capture activities.

Specified by:
close in interface Closeable
Overrides:
close in class InputStream
Throws:
IOException

read

public int read()
         throws IOException

This implementation throws UnsupportedOperationException.

Specified by:
read in class InputStream
Throws:
IOException

read

public int read(byte[] buffer)
         throws IOException

This implementation throws UnsupportedOperationException.

Overrides:
read in class InputStream
Throws:
IOException

read

public int read(byte[] buffer,
                int offset,
                int length)
         throws IOException

This implementation throws UnsupportedOperationException.

Overrides:
read in class InputStream
Throws:
IOException

readPacket

public abstract Packet readPacket()
                           throws SocketTimeoutException,
                                  EOFException,
                                  IOException
Read a Packet from the network or savefile, depending on how the stream was constructed.

Returns:
a Packet.
Throws:
SocketTimeoutException - The timeout specified when the capture device was opened has expired without a packet being captured.
EOFException - End of a savefile has been reached.
IOException - I/O problem reading packet.

Copyright © Patrick Charles & Jonas Lehmann, 2001; Esmond Pitt, 2008.