org.jboss.remoting.transport.multiplex
Class MultiplexingOutputStream

java.lang.Object
  extended byjava.io.OutputStream
      extended byorg.jboss.remoting.transport.multiplex.MultiplexingOutputStream

public class MultiplexingOutputStream
extends java.io.OutputStream

Copyright (c) 2005

Author:
Ron Sigal

Field Summary
protected static org.jboss.logging.Logger log
           
 
Constructor Summary
MultiplexingOutputStream(MultiplexingManager manager, SocketId socketId)
           
MultiplexingOutputStream(MultiplexingManager manager, VirtualSocket virtualSocket, SocketId socketId)
           
 
Method Summary
protected  void checkStatus()
          Determines how to handle a write request depending on what this socket knows about the state of the peer socket.
 void close()
           
 void flush()
           
protected  void handleRemoteDisconnect()
          FIXME Comment this
protected  void shutdown()
          FIXME Comment this
 void write(byte[] array)
           
 void write(byte[] array, int off, int len)
           
 void write(int i)
           
protected  void write(int i, int brackets)
          FIXME Comment this
protected  void writeInt(int i, int brackets)
          FIXME Comment this
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.jboss.logging.Logger log
Constructor Detail

MultiplexingOutputStream

public MultiplexingOutputStream(MultiplexingManager manager,
                                SocketId socketId)
Parameters:
manager -
socketId -

MultiplexingOutputStream

public MultiplexingOutputStream(MultiplexingManager manager,
                                VirtualSocket virtualSocket,
                                SocketId socketId)
Parameters:
manager -
virtualSocket - TODO
socketId -
Method Detail

close

public void close()
           throws java.io.IOException
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Throws:
java.io.IOException

write

public void write(int i)
           throws java.io.IOException
Throws:
java.io.IOException

write

public void write(byte[] array)
           throws java.io.IOException,
                  java.lang.NullPointerException
Throws:
java.io.IOException
java.lang.NullPointerException

write

public void write(byte[] array,
                  int off,
                  int len)
           throws java.io.IOException,
                  java.lang.NullPointerException,
                  java.lang.IndexOutOfBoundsException
Throws:
java.io.IOException
java.lang.NullPointerException
java.lang.IndexOutOfBoundsException

checkStatus

protected void checkStatus()
                    throws java.io.IOException
Determines how to handle a write request depending on what this socket knows about the state of the peer socket.

Once this socket knows that the peer socket has closed, no more write requests will be honored. There seem to be two ways for a socket A to learn that its peer socket B has closed.

  1. If socket A has executed a write, but no subsequent write is performed on B, then the acknowledgement of the write will carry back the information that B has closed.
  2. If socket B has no pending acknowledgements to send at the time it closes, and then socket A does a write after B has closed, the (negative) acknowledgement of the write will carry back the information that B has closed.

Java seems to respond differently to the two cases. The first write after this socket has learned of the peer's closing through the first scenario will result in a SocketException("Connection reset"). In the second scenario, the first write by this socket after the peer has closed will quietly fail (no exception is thrown). All subsequent writes after either of these two scenarios will result in a SocketException("Broken pipe").

Currently, MultiplexingOutputStream implements only a simplified version of this behavior. In particular, it allows in all cases one write to silently fail, after which all writes result in a SocketException("Broken pipe");

Note. This discussion is based on empirical observation on a linux system, not on examination of code. Your mileage may vary.

Throws:
java.io.IOException

handleRemoteDisconnect

protected void handleRemoteDisconnect()
FIXME Comment this


shutdown

protected void shutdown()
FIXME Comment this


write

protected void write(int i,
                     int brackets)
              throws java.io.IOException
FIXME Comment this

Parameters:
i -
brackets -
Throws:
java.io.IOException

writeInt

protected void writeInt(int i,
                        int brackets)
                 throws java.io.IOException
FIXME Comment this

Parameters:
i -
brackets -
Throws:
java.io.IOException


Copyright ? 1998-2005 JBoss Inc . All Rights Reserved.