OutputStream writeChannel(int channel) throws IOException {
  while (os != null) {
    boolean canWrite=false;
synchronized (WRITE_LOCK) {
      if (!isWriteLocked) {
        isWriteLocked=true;
        canWrite=true;
      }
 else {
        try {
          WRITE_LOCK.wait(5000);
        }
 catch (        Exception e) {
        }
      }
    }
    if (canWrite) {
      os.write('C');
      os.write(channel >> 8);
      os.write(channel);
      return os;
    }
  }
  return null;
}

OutputStream writeChannel ( int channel ) throws IOException { while ( os != null ) { boolean canWrite = false ; synchronized ( WRITE_LOCK ) { if ( ! isWriteLocked ) { isWriteLocked = true ; canWrite = true ; } else { try { WRITE_LOCK . wait ( 5000 ) ; } catch ( Exception e ) { } } } if ( canWrite ) { os . write ( 'C' ) ; os . write ( channel > > 8 ) ; os . write ( channel ) ; return os ; } } return null ; }
grabs the channel for writing .
