SunSPOT API V6.0


com.sun.spot.ipv6.tcp
Class TCPInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.sun.spot.ipv6.tcp.TCPInputStream

public class TCPInputStream
extends InputStream

Helper class for "tcp:" connections. This class provides an InputStream over the data received from another Spot. It also provides a small set of accessors to get information about the quality of the link. You should NOT normally instantiate this class directly, but rather via the GCF framework: see the first reference below for more details.

See Also:
TCPConnection

Constructor Summary
TCPInputStream(Socket s)
          Construct a TCPInputStream, using the TCP socket provided.
 
Method Summary
 int available()
          Return the number of bytes available to be read from the stream without blocking.
 void close()
          Closes this input stream.
 long getTimeout()
          returns the time, in milliseconds, this connection will wait for data before throwing a timeout exception
 int read()
          Reads the next byte of data from the input stream.
 void setTimeout(int time)
          change the timeout associated with this input stream
 
Methods inherited from class java.io.InputStream
mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TCPInputStream

public TCPInputStream(Socket s)
Construct a TCPInputStream, using the TCP socket provided.

Parameters:
s - The socket to be used when reading input
Method Detail

read

public int read()
         throws IOException
Description copied from class: InputStream
Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

A subclass must provide an implementation of this method.

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

available

public int available()
              throws IOException
Return the number of bytes available to be read from the stream without blocking. Returns the number of bytes available in the current underlying TCP stream - more packets might be coming but we just don't know.

Overrides:
available in class InputStream
Returns:
the number of bytes available right now
Throws:
IOException

close

public void close()
           throws IOException
Closes this input stream. First, it tells the underlying TCP connection to push any data remaining.

Overrides:
close in class InputStream
Throws:
IOException

setTimeout

public void setTimeout(int time)
change the timeout associated with this input stream

Parameters:
time - time, in milliseconds, to wait for data on this input stream

getTimeout

public long getTimeout()
returns the time, in milliseconds, this connection will wait for data before throwing a timeout exception

Returns:
input timeout, in milliseconds

SunSPOT API V6.0


Copyright © 2006-2010 Oracle. All Rights Reserved.