org.web3d.vrtp.util
Class ADUStreamTCP

java.lang.Object
  |
  +--org.web3d.vrtp.util.ADUStream
        |
        +--org.web3d.vrtp.util.ADUStreamTCP
All Implemented Interfaces:
DatasourceIF

public class ADUStreamTCP
extends ADUStream

ADUStreamTCP

This class reads one or more ADUs from a TCP socket. There may be several ADUs transmitted across the TCP socket.

Author:
Don McGregor mcgredo@nps.navy.mil

Field Summary
(package private)  byte[] inputBuffer
           
(package private)  int offset
           
 
Fields inherited from class org.web3d.vrtp.util.ADUStream
isReading, protocol
 
Constructor Summary
ADUStreamTCP(java.net.Socket pSocket, ProtocolDescription pProtocol)
          constructor, called by subclasses.
 
Method Summary
 java.util.Vector getADUs()
          Threaded access.
 boolean hasNext()
          returns true if there are more ADUs available from the input source.
static void main(java.lang.String[] args)
           
 ADUData readNext()
          Returns the next ADUData in the input stream.
 void resumeReading()
          resume reading again
 void run()
          Runnable interface, for threads
 void stopReading()
          stop thread reading
 void writeADU(ADUData pAdu)
          ADU to be written.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inputBuffer

byte[] inputBuffer

offset

int offset
Constructor Detail

ADUStreamTCP

public ADUStreamTCP(java.net.Socket pSocket,
                    ProtocolDescription pProtocol)
constructor, called by subclasses.
Method Detail

hasNext

public boolean hasNext()
returns true if there are more ADUs available from the input source. If there are zero bytes available to read, this returns false. Otherwise it returns true. Note that there may be more bytes available to read at some time in the future, when someone sends something.
Overrides:
hasNext in class ADUStream

readNext

public ADUData readNext()
Returns the next ADUData in the input stream. Might return null if there are no ADUs available to be read.
Overrides:
readNext in class ADUStream

getADUs

public java.util.Vector getADUs()
Threaded access. If the object gets kicked off in a thread, these methods can be used to return packets
Overrides:
getADUs in class ADUStream

stopReading

public void stopReading()
stop thread reading
Overrides:
stopReading in class ADUStream

resumeReading

public void resumeReading()
resume reading again
Overrides:
resumeReading in class ADUStream

run

public void run()
Runnable interface, for threads
Overrides:
run in class ADUStream

writeADU

public void writeADU(ADUData pAdu)
Description copied from class: ADUStream
ADU to be written. This might require some extra work in subclasses.
Overrides:
writeADU in class ADUStream

main

public static void main(java.lang.String[] args)