jist.swans.trans
Class TcpInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by jist.swans.app.io.InputStream
          extended by jist.swans.trans.TcpInputStream
All Implemented Interfaces:
java.io.Closeable

public class TcpInputStream
extends InputStream

SWANS Implementation of InputStream for Socket.

Since:
SWANS1.0
Version:
$Id: TcpInputStream.java,v 1.7 2004/04/06 16:07:51 barr Exp $
Author:
Kelwin Tamtoro <kt222@cs.cornell.edu>, Rimon Barr <barr+jist@cs.cornell.edu>

Field Summary
(package private)  boolean isClosed
          The closed state of the output stream.
(package private)  SocketInterface.TcpSocketInterface socketEntity
          Entity reference to Socket object.
 
Constructor Summary
TcpInputStream(SocketInterface.TcpSocketInterface entity)
          Constructor.
 
Method Summary
 void close()
          Closes this input stream and releases any system resources associated with the stream.
 int read()
          Reads the next byte of data from the input stream.
 int read(byte[] b)
          Reads some number of bytes from the input stream and stores them into the buffer array b.
 int read(byte[] b, int off, int len)
          Reads up to len bytes of data from the input stream into an array of bytes.
 
Methods inherited from class jist.swans.app.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
 

Field Detail

socketEntity

SocketInterface.TcpSocketInterface socketEntity
Entity reference to Socket object.


isClosed

boolean isClosed
The closed state of the output stream.

Constructor Detail

TcpInputStream

public TcpInputStream(SocketInterface.TcpSocketInterface entity)
Constructor.

Parameters:
entity - entity reference to Socket
Method Detail

close

public void close()
           throws java.io.IOException
Closes this input stream and releases any system resources associated with the stream.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class InputStream
Throws:
java.io.IOException - if an I/O error occurs
See Also:
InputStream

read

public int read()
         throws java.io.IOException
Reads the next byte of data from the input stream.

Specified by:
read in class InputStream
Returns:
the next byte of data, or -1 if the end of the stream is reached.
Throws:
java.io.IOException - if an I/O error occurs
See Also:
InputStream

read

public int read(byte[] b)
         throws java.io.IOException
Reads some number of bytes from the input stream and stores them into the buffer array b.

Overrides:
read in class InputStream
Parameters:
b - the buffer into which the data is read.
Returns:
the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached.
Throws:
java.io.IOException - if an I/O error occurs
See Also:
InputStream

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Reads up to len bytes of data from the input stream into an array of bytes.

Overrides:
read in class InputStream
Parameters:
b - the buffer into which the data is read.
off - the start offset in array b at which the data is written.
len - the maximum number of bytes to read.
Returns:
the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached.
Throws:
java.io.IOException - if an I/O error occurs
See Also:
InputStream