Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.remoting.transport.multiplex
Class MultiplexingOutputStream

    java.lang.Object
      java.io.OutputStream
          org.jboss.remoting.transport.multiplex.MultiplexingOutputStream

All Implemented Interfaces:
  java.io.Closeable, java.io.Flushable

    public class MultiplexingOutputStream

extends java.io.OutputStream

`MultiplexingOutputStream` is the class returned by `VirtualSocket.getOutputStream()`. It supports the methods and behavior implemented by the `OutputStream` returned by `java.net.Socket.getOutputStream()`. For more information about the behavior of the methods, see the javadoc for `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()` See superclass javadoc.
`void` | `flush()` See superclass javadoc.
`protected void` | `handleRemoteDisconnect()`
`protected void` | `setWriteException(java.io.IOException e)`
`protected void` | `shutdown()`
`void` | `write(byte[] array)` See superclass javadoc.
`void` | `write(byte[] array, int off, int len)` See superclass javadoc.
`void` | `write(int i)` See superclass javadoc.
`protected void` | `write(int i, int brackets)`
`void` | `writeInt(int i)` `writeInt()` is borrowed from `DataOutputStream`.
`protected void` | `writeInt(int i, int brackets)`

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` -
  `socketId` -

Method Detail

### close

    public void close()
               throws java.io.IOException

  See superclass javadoc.

  Specified by:
    `close` in interface `java.io.Closeable`
  Overrides:
    `close` in class `java.io.OutputStream`
  Throws:
    `java.io.IOException`

### flush

    public void flush()
               throws java.io.IOException

  See superclass javadoc.

  Specified by:
    `flush` in interface `java.io.Flushable`
  Overrides:
    `flush` in class `java.io.OutputStream`
  Throws:
    `java.io.IOException`

### write

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

  See superclass javadoc.

  Specified by:
    `write` in class `java.io.OutputStream`
  Throws:
    `java.io.IOException`

### write

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

  See superclass javadoc.

  Overrides:
    `write` in class `java.io.OutputStream`
  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

  See superclass javadoc.

  Overrides:
    `write` in class `java.io.OutputStream`
  Throws:
    `java.io.IOException`
    `java.lang.NullPointerException`
    `java.lang.IndexOutOfBoundsException`

### setWriteException

    protected void setWriteException(java.io.IOException e)

### writeInt

    public void writeInt(int i)
                  throws java.io.IOException

  `writeInt()` is borrowed from `DataOutputStream`. It saves the extra expense of creating a `DataOutputStream`.

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

### 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()

### shutdown

    protected void shutdown()

### write

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

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

### writeInt

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

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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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