verinec.netsim.util.net.sockets
Class SocketInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by verinec.netsim.util.net.sockets.SocketInputStream
All Implemented Interfaces:
Closeable

public class SocketInputStream
extends InputStream

A SocketInputStream that gets it's data from a SocketImpl.

Version:
$Revision: 794 $
Author:
Dominik Jungo

Field Summary
private  SlidingWindowByteBuffer buffer
           
private  SocketImpl impl
           
private  Logger jlogger
           
 
Constructor Summary
SocketInputStream(SocketImpl impl)
          Constructs a new SocketInputStream that gets it's data from a SocketImpl
 
Method Summary
 void addPacket(TCPPacket packet)
          adds a Packet to this streams buffer
 void close()
           
 int getAck()
          gets the address of the last part of the buffer that can be acknowledged
 int getWindowSize()
          gets the window size of the buffer
 int read()
          reads one byte of data from this buffer
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

impl

private SocketImpl impl

buffer

private SlidingWindowByteBuffer buffer

jlogger

private Logger jlogger
Constructor Detail

SocketInputStream

public SocketInputStream(SocketImpl impl)
                  throws IOException
Constructs a new SocketInputStream that gets it's data from a SocketImpl

Parameters:
impl - a SocketImpl
Throws:
IOException - if an I/O error occurs
Method Detail

read

public int read()
         throws IOException
reads one byte of data from this buffer

Specified by:
read in class InputStream
Throws:
IOException - if teh connection is closed
See Also:
InputStream.read()

getWindowSize

public int getWindowSize()
gets the window size of the buffer

Returns:
the window size of the buffer

getAck

public int getAck()
gets the address of the last part of the buffer that can be acknowledged

Returns:
the address of the last part of the buffer that can be acknowledged

addPacket

public void addPacket(TCPPacket packet)
               throws NetSimException
adds a Packet to this streams buffer

Parameters:
packet - a Packet to be added to the buffer
Throws:
NetSimException - if the Packet can't be added to the buffer, e.g. the buffer is full

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class InputStream
Throws:
IOException
See Also:
InputStream.close()

Copyright © 2005 Verinec, DIUF