public synchronized TCPConnection openConnection() throws IOException {
  int id;
  do {
    lastID=(++lastID) & 0x7FFF;
    id=lastID;
    if (orig)     id|=0x8000;
  }
 while (connectionTable.get(id) != null);
  MultiplexConnectionInfo info=new MultiplexConnectionInfo(id);
  info.in=new MultiplexInputStream(this,info,2048);
  info.out=new MultiplexOutputStream(this,info,2048);
synchronized (connectionTable) {
    if (!alive)     throw new IOException("Multiplexer connection dead");
    if (numConnections >= maxConnections)     throw new IOException("Cannot exceed " + maxConnections + " simultaneous multiplexed connections");
    connectionTable.put(id,info);
    ++numConnections;
  }
synchronized (dataOut) {
    try {
      dataOut.writeByte(OPEN);
      dataOut.writeShort(id);
      dataOut.flush();
    }
 catch (    IOException e) {
      multiplexLog.log(Log.BRIEF,"exception: ",e);
      shutDown();
      throw e;
    }
  }
  return new TCPConnection(channel,info.in,info.out);
}

public synchronized TCPConnection openConnection ( ) throws IOException { int id ; do { lastID = ( ++ lastID ) & 0x7FFF ; id = lastID ; if ( orig ) id |= 0x8000 ; } while ( connectionTable . get ( id ) != null ) ; MultiplexConnectionInfo info = new MultiplexConnectionInfo ( id ) ; info . in = new MultiplexInputStream ( this , info , 2048 ) ; info . out = new MultiplexOutputStream ( this , info , 2048 ) ; synchronized ( connectionTable ) { if ( ! alive ) throw new IOException ( "Multiplexer connection dead" ) ; if ( numConnections >= maxConnections ) throw new IOException ( "Cannot exceed " + maxConnections + " simultaneous multiplexed connections" ) ; connectionTable . put ( id , info ) ; ++ numConnections ; } synchronized ( dataOut ) { try { dataOut . writeByte ( OPEN ) ; dataOut . writeShort ( id ) ; dataOut . flush ( ) ; } catch ( IOException e ) { multiplexLog . log ( Log . BRIEF , "exception: " , e ) ; shutDown ( ) ; throw e ; } } return new TCPConnection ( channel , info . in , info . out ) ; }
initiate a new multiplexed connection through the underlying connection .
