seda.sandStorm.lib.aSocket
Class aSocketInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by seda.nbio.NonblockingInputStream
          extended by seda.sandStorm.lib.util.MultiByteArrayInputStream
              extended by seda.sandStorm.lib.aSocket.aSocketInputStream
All Implemented Interfaces:
java.io.Closeable

public class aSocketInputStream
extends MultiByteArrayInputStream

This is a utility class that allows you to push multiple ATcpInPackets in, and read bytes out as a stream. This is meant to be a convenience for performing packet processing using the aSocket interfaces. This class also takes care of reordering packets according to the ATcpInPacket sequence number; that is, if multiple threads in a stage are receiving ATcpInPackets for the same connection, the aSocketInputStream will internally reorder those packets.

See Also:
MultiByteArrayInputStream

Nested Class Summary
(package private)  class aSocketInputStream.seqNumComparator
           
 
Field Summary
private static boolean DEBUG
           
private  long nextSeqNum
           
private  java.util.TreeSet outoforder
           
 
Constructor Summary
aSocketInputStream()
          Create an aSocketInputStream with an initial sequence number of 1.
aSocketInputStream(long initialSeqNum)
          Create an aSocketInputStream using the given initial sequence number.
 
Method Summary
 void addPacket(ATcpInPacket pkt)
          Add a packet to this aSocketInputStream.
 void clear()
          Reinitialize the state of this input stream, clearing all internal data and pointers.
 long getNextSequenceNumber()
          Return the next expected sequence number.
 
Methods inherited from class seda.sandStorm.lib.util.MultiByteArrayInputStream
addArray, available, close, mark, markSupported, nbRead, numArrays, read, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

private static final boolean DEBUG
See Also:
Constant Field Values

outoforder

private java.util.TreeSet outoforder

nextSeqNum

private long nextSeqNum
Constructor Detail

aSocketInputStream

public aSocketInputStream()
Create an aSocketInputStream with an initial sequence number of 1.


aSocketInputStream

public aSocketInputStream(long initialSeqNum)
Create an aSocketInputStream using the given initial sequence number.

Method Detail

addPacket

public void addPacket(ATcpInPacket pkt)
Add a packet to this aSocketInputStream. Reorders packets internally so that bytes will be read from this InputStream according to the sequence number order of the packets.


clear

public void clear()
Reinitialize the state of this input stream, clearing all internal data and pointers. The next sequence number will be preserved.

Overrides:
clear in class MultiByteArrayInputStream

getNextSequenceNumber

public long getNextSequenceNumber()
Return the next expected sequence number.