org.jivesoftware.smackx.bytestreams.ibb
Class InBandBytestreamSession

java.lang.Object
  extended by org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamSession
All Implemented Interfaces:
BytestreamSession

public class InBandBytestreamSession
extends java.lang.Object
implements BytestreamSession

InBandBytestreamSession class represents an In-Band Bytestream session.

In-band bytestreams are bidirectional and this session encapsulates the streams for both directions.

Note that closing the In-Band Bytestream session will close both streams. If both streams are closed individually the session will be closed automatically once the second stream is closed. Use the setCloseBothStreamsEnabled(boolean) method if both streams should be closed automatically if one of them is closed.

Author:
Henning Staib

Method Summary
 void close()
          Closes the bytestream session.
 java.io.InputStream getInputStream()
          Returns the InputStream associated with this session to send data.
 java.io.OutputStream getOutputStream()
          Returns the OutputStream associated with this session to receive data.
 int getReadTimeout()
          Returns the timeout for read operations of the input stream associated with this session.
 boolean isCloseBothStreamsEnabled()
          Returns whether both streams should be closed automatically if one of the streams is closed.
 void setCloseBothStreamsEnabled(boolean closeBothStreamsEnabled)
          Sets whether both streams should be closed automatically if one of the streams is closed.
 void setReadTimeout(int timeout)
          Sets the specified timeout, in milliseconds.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInputStream

public java.io.InputStream getInputStream()
Description copied from interface: BytestreamSession
Returns the InputStream associated with this session to send data.

Specified by:
getInputStream in interface BytestreamSession
Returns:
the InputStream associated with this session to send data

getOutputStream

public java.io.OutputStream getOutputStream()
Description copied from interface: BytestreamSession
Returns the OutputStream associated with this session to receive data.

Specified by:
getOutputStream in interface BytestreamSession
Returns:
the OutputStream associated with this session to receive data

getReadTimeout

public int getReadTimeout()
Description copied from interface: BytestreamSession
Returns the timeout for read operations of the input stream associated with this session. 0 returns implies that the option is disabled (i.e., timeout of infinity). Default is 0.

Specified by:
getReadTimeout in interface BytestreamSession
Returns:
the timeout for read operations

setReadTimeout

public void setReadTimeout(int timeout)
Description copied from interface: BytestreamSession
Sets the specified timeout, in milliseconds. With this option set to a non-zero timeout, a read() call on the input stream associated with this session will block for only this amount of time. If the timeout expires, a java.net.SocketTimeoutException is raised, though the session is still valid. The option must be enabled prior to entering the blocking operation to have effect. The timeout must be > 0. A timeout of zero is interpreted as an infinite timeout. Default is 0.

Specified by:
setReadTimeout in interface BytestreamSession
Parameters:
timeout - the specified timeout, in milliseconds

isCloseBothStreamsEnabled

public boolean isCloseBothStreamsEnabled()
Returns whether both streams should be closed automatically if one of the streams is closed. Default is false.

Returns:
true if both streams will be closed if one of the streams is closed, false if both streams can be closed independently.

setCloseBothStreamsEnabled

public void setCloseBothStreamsEnabled(boolean closeBothStreamsEnabled)
Sets whether both streams should be closed automatically if one of the streams is closed. Default is false.

Parameters:
closeBothStreamsEnabled - true if both streams should be closed if one of the streams is closed, false if both streams should be closed independently

close

public void close()
           throws java.io.IOException
Description copied from interface: BytestreamSession
Closes the bytestream session.

Closing the session will also close the input stream and the output stream associated to this session.

Specified by:
close in interface BytestreamSession
Throws:
java.io.IOException - if an error occurs while closing the session