Class w3c.www.mux.MuxStream
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

Variable Index

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

Constructor Index

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

Method Index

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

Variables

 o handler
  protected MuxStreamHandler handler
That stream accept handler.
 o reader
  protected MuxReader reader
This stream reader.
 o writer
  protected MuxWriter writer
This stream writer.
 o sessions
  protected MuxSession sessions[]
Currently defined sessions.
 o server
  protected boolean server
Is this the server side of the MUX channel ?
 o inetaddr
  protected InetAddress inetaddr
Inet address of the other end's connection (maybe null)
 o in
  protected InputStream in
The raw input stream.
 o out
  protected OutputStream out
The raw output stream.
 o alive
  protected boolean alive
Is this muxed stream still alive ?

Constructors

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

Methods

 o getMuxWriter
  protected final MuxWriter getMuxWriter()
Get this stream MuxWriter object.
Returns:
A MuxWriter instance.
 o 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).
 o 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.
 o 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.
 o 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).
 o 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.
 o 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.
 o 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.
 o 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.
 o unregisterSession
  protected synchronized void unregisterSession(MuxSession session)
Unregiter the given session, it has been closed.
Parameters:
session - The session to unregister.
 o 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.
 o 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.
 o 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