    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class w3c.mux.MPStream

    java.lang.Object
       |
       +----w3c.mux.MPStream

public class MPStream
extends Object
implements MUX

##

DEFINCR
DEFSIZE

##

MPStream(boolean, InputStream, OutputStream)
  Build a multiplexed stream out of the given streams.
MPStream(boolean, Socket)
  Build a multiplexed stream out of the given socket.

##

accept()
accept(int)
  Accept any incoming connection on this stream.
allocateSession(int, int)
  Allocate a new session.
checkAccept(int)
  Check for session waiting for accept:
connect()
  Connect to target, using any session identifier, and without protocol.
connect(int)
  Connect to target, to speak the given protocol.
connect(int, byte[], int, int)
  Connect to target, to speak the given protocol, send data.
connect(int, int, byte[], int, int)
  Connect to the other end, using the given protocol id.
fin(byte, int, int)
  Close the corresponding input stream of the session.
getFakeSession()
  Get this MPStream fake session (used for accepting new connections)
getReader()
  Get this MPStream reader object.
getSession(byte, int)
getSession(byte, int, int)
  Get the session associated with the given session id.
getSession(int)
getWriter()
  Get this MPStream writer object.
lookupSession(int)
push(byte, int, int)
rst(byte, int, int)
syn(byte, int, int)
unregisterSession(Session)
  Unregister the given session.

##

DEFSIZE

      public final static int DEFSIZE

DEFINCR

      public final static int DEFINCR

##

MPStream

      public MPStream(boolean server,
                      InputStream input,
                      OutputStream output) throws IOException

  Build a multiplexed stream out of the given streams.
  Parameters:
    server - Am I server on this connection ?
    input - The input stream to multiplex.
    output - The output stream to multiplex.

MPStream

      public MPStream(boolean server,
                      Socket socket) throws IOException

  Build a multiplexed stream out of the given socket.
  Parameters:
    server - Should this end of the multiplexer act as the server or as the client.
    socket - The socket to multiplex.

##

getFakeSession

      protected Session getFakeSession()

  Get this MPStream fake session (used for accepting new connections)

getReader

      protected MPReader getReader()

  Get this MPStream reader object.

getWriter

      protected MPWriter getWriter()

  Get this MPStream writer object.

allocateSession

      protected synchronized Session allocateSession(int id,
                                                     int protid) throws IOException

  Allocate a new session. If the provided id is positive, we try to allocate this one, otherwise we allocate the first available one.
  Parameters:
    id - The identifier of the session to allocate.
  Returns:
    A Session instance.
  Throws: IOException
    If the provided session identifier is invalid.

getSession

      protected synchronized Session getSession(byte flags,
                                                int id,
                                                int protid) throws IOException

  Get the session associated with the given session id. If such a session doesn't exist, try creating it.
  Parameters:
    id - The session identifier.

getSession

      protected Session getSession(byte flags,
                                   int id) throws IOException

getSession

      protected Session getSession(int id) throws IOException

lookupSession

      protected synchronized Session lookupSession(int id)

unregisterSession

      protected synchronized void unregisterSession(Session session)

  Unregister the given session. The session should have been closed properly (both its input and its output). This method will than unregister any knowledge we have of it, in particular, its session identifier will be available for reuse.
  Parameters:
    session - The session to unregister.

syn

      protected synchronized void syn(byte flags,
                                      int id,
                                      int protid)

fin

      protected synchronized void fin(byte flags,
                                      int id,
                                      int protid) throws IOException

  Close the corresponding input stream of the session. This method is invoked by the reader, when it receives a message with the FIN bit set. The corresponding input session stream is to be closed and any reader need to be notified of the close operation.
  Parameters:
    flags - Flags of the received message.
    id - The session identitifer of the message.
    protid - The protocol running on this session (or -1).
  Throws: RuntimeException
    If the FIN message is for an unexsiting session.

rst

      protected synchronized void rst(byte flags,
                                      int id,
                                      int protid)

push

      protected synchronized void push(byte flags,
                                       int id,
                                       int protid)

connect

      public Session connect(int id,
                             int protocol,
                             byte buf[],
                             int off,
                             int len) throws IOException

  Connect to the other end, using the given protocol id.
  Parameters:
    session - The session to use.
    protocol - The protocol number to use on this session.
    buf - Associated data (can be null).
    off - Offset in the provided buffer.
    len - Length in the provided buffer.

connect

      public Session connect(int protocol) throws IOException

  Connect to target, to speak the given protocol.
  Parameters:
    protocol - The protocol identfier to speak on the new session.

connect

      public Session connect(int protocol,
                             byte buf[],
                             int off,
                             int len) throws IOException

  Connect to target, to speak the given protocol, send data.
  Parameters:
    protocol - The protocol to speak on the new session.
    buf - The data to send with the connection packet.
    buf - The buffer containing the data.
    off - Offset in the buffer.
    len - Length of data to send.

connect

      public Session connect() throws IOException

  Connect to target, using any session identifier, and without protocol.

checkAccept

      protected synchronized Session checkAccept(int protid) throws IOException

  Check for session waiting for accept:

accept

      public Session accept(int protid) throws IOException

  Accept any incoming connection on this stream.

accept

      public Session accept() throws IOException

    All Packages  Class Hierarchy  This Package  Previous  Next  Index