code: 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;
      }
docs: Grabs the channel for writing.
  
  @param channel the channel
  
  @return true if the channel has permission to write.