    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class w3c.www.mux.MuxStream

    java.lang.Object
       |
       +----w3c.www.mux.MuxStream

public class MuxStream
extends Object

##

alive
  Is this muxed stream still alive ?
handler
  That stream accept handler.
in
  The raw input stream.
inetaddr
  Inet address of the other end's connection (maybe null)
out
  The raw output stream.
reader
  This stream reader.
server
  Is this the server side of the MUX channel ?
sessions
  Currently defined sessions.
writer
  This stream writer.

##

MuxStream(boolean, MuxStreamHandler, InputStream, OutputStream)
MuxStream(boolean, MuxStreamHandler, Socket)

##

connect(int)
  Create a new MUX session, by connecting to the other end.
ctrlDefineStack(int, int[])
  Handle the given DefineStack control message.
ctrlDefineString(int, String)
  Handle the given DefineString control message.
ctrlMuxControl(int, int)
  Handle the given MuxControl control message.
ctrlSendCredit(int, int)
  Handle the given SendCredit control message.
error(Object, Exception)
  A severe (fatal for that connection) errror has occured.
error(Object, String)
  A soft error has occured (eg socket close), Cleanup.
getInetAddress()
  Get the InetAddress associated with that MUX stream, if any.
getMuxWriter()
  Get this stream MuxWriter object.
lookupSession(int, boolean)
  Lookup for an already existing session having the given identifier.
lookupSession(int, int, int, int)
  Handle that new incomming message.
shutdown(boolean)
  Shutdown this stream, and associated sessions gracefully.
unregisterSession(MuxSession)
  Unregiter the given session, it has been closed.

##

handler

     protected MuxStreamHandler handler

  That stream accept handler.

reader

     protected MuxReader reader

  This stream reader.

writer

     protected MuxWriter writer

  This stream writer.

sessions

     protected MuxSession sessions[]

  Currently defined sessions.

server

     protected boolean server

  Is this the server side of the MUX channel ?

inetaddr

     protected InetAddress inetaddr

  Inet address of the other end's connection (maybe null)

in

     protected InputStream in

  The raw input stream.

out

     protected OutputStream out

  The raw output stream.

alive

     protected boolean alive

  Is this muxed stream still alive ?

##

MuxStream

     public MuxStream(boolean server,
                      MuxStreamHandler handler,
                      InputStream in,
                      OutputStream out) throws IOException

MuxStream

     public MuxStream(boolean server,
                      MuxStreamHandler handler,
                      Socket socket) throws IOException

##

getMuxWriter

     protected final MuxWriter getMuxWriter()

  Get this stream MuxWriter object.

  Returns:
    A MuxWriter instance.

error

     protected void error(Object obj,
                          Exception ex)

  A severe (fatal for that connection) errror has occured. Cleanup.

  Parameters:
    obj - The object that has generated the error.
    ex - The exception that triggered the error (or null null if this was a logical error).

error

     protected synchronized void error(Object obj,
                                       String msg)

  A soft error has occured (eg socket close), Cleanup.

  Parameters:
    obj - The object that has detected the soft error.
    msg - An associated String message.

ctrlDefineString

     protected void ctrlDefineString(int strid,
                                     String str)

  Handle the given DefineString control message.

  Parameters:
    strid - The identifier for that String in the futur.
    str - This String being defined.

ctrlDefineStack

     protected void ctrlDefineStack(int id,
                                    int stack[]) throws IOException

  Handle the given DefineStack control message.

  Parameters:
    id - The identifier for that stack in the future.
    stack - The stack description (as an array of shorts).

ctrlMuxControl

     protected void ctrlMuxControl(int sessid,
                                   int fragsz) throws IOException

  Handle the given MuxControl control message.

  Parameters:
    sessid - The session to which that message applies.
    fragsz - The max allowed fragment size on that session.

ctrlSendCredit

     protected void ctrlSendCredit(int sessid,
                                   int credit) throws IOException

  Handle the given SendCredit control message.

  Parameters:
    sessid - The session to which that message applies.
    credit - The allowed credits.

lookupSession

     protected MuxSession lookupSession(int flags,
                                        int sessid,
                                        int length,
                                        int llength) throws IOException

  Handle that new incomming message. This method is called by the reader of that session, to dispatch the message currently being read.

  Returns:
    A MuxSession instance to dispatch that message to, or null otherwise (ie a new session was rejected, etc). In that last case, it is up to the reader of that session to discard any pending data.

lookupSession

     protected synchronized MuxSession lookupSession(int sessid,
                                                     boolean check)

  Lookup for an already existing session having the given identifier.

  Parameters:
    sessid - The identifier of the session to look for.
    check - Is null a valid answer, if set and the requested session doesn't exist, a runtime exception is thrown.
  Returns:
    A MuxSession instance, or null if check is false and no session was found.

unregisterSession

     protected synchronized void unregisterSession(MuxSession session)

  Unregiter the given session, it has been closed.

  Parameters:
    session - The session to unregister.

connect

     public MuxSession connect(int protid) throws IOException

  Create a new MUX session, by connecting to the other end.

  Parameters:
    protid - The protocol that is going to be spoken on that new session.
  Returns:
    A connected MuxSession.
  Throws: IOException
    If the connection couldn't be set up properly.

getInetAddress

     public InetAddress getInetAddress()

  Get the InetAddress associated with that MUX stream, if any. MUX streams can run on any kind of Input/Output streams. This method will only return a non-null instance when possible.

  Returns:
    An InetAddress instance, or null if not available.

shutdown

     public synchronized boolean shutdown(boolean force) throws IOException

  Shutdown this stream, and associated sessions gracefully.

  Parameters:
    force - If true abort all existing sessions, and close the muxed streams physically. Otherwise, shutdown the muxed stream gracefully only if no more sessions are running.
  Returns:
    A boolean, true if shutdown was performed, false if it was not performed because force was false and some sessions were still running.
  Throws: IOException
    If some IO error occured.

    All Packages  Class Hierarchy  This Package  Previous  Next  Index