public synchronized void write(byte b[],int off,int len) throws IOException {
  if (len <= 0)   return;
  int freeSpace=buffer.length - pos;
  if (len <= freeSpace) {
    System.arraycopy(b,off,buffer,pos,len);
    pos+=len;
    return;
  }
  flush();
  int local_requested;
  while (true) {
synchronized (lock) {
      while ((local_requested=requested) < 1 && !disconnected) {
        try {
          lock.wait();
        }
 catch (        InterruptedException e) {
        }
      }
      if (disconnected)       throw new IOException("Connection closed");
    }
    if (local_requested < len) {
      manager.sendTransmit(info,b,off,local_requested);
      off+=local_requested;
      len-=local_requested;
synchronized (lock) {
        requested-=local_requested;
      }
    }
 else {
      manager.sendTransmit(info,b,off,len);
synchronized (lock) {
        requested-=len;
      }
      break;
    }
  }
}

public synchronized void write ( byte b [ ] , int off , int len ) throws IOException { if ( len <= 0 ) return ; int freeSpace = buffer . length - pos ; if ( len <= freeSpace ) { System . arraycopy ( b , off , buffer , pos , len ) ; pos += len ; return ; } flush ( ) ; int local_requested ; while ( true ) { synchronized ( lock ) { while ( ( local_requested = requested ) < 1 && ! disconnected ) { try { lock . wait ( ) ; } catch ( InterruptedException e ) { } } if ( disconnected ) throw new IOException ( "Connection closed" ) ; } if ( local_requested < len ) { manager . sendTransmit ( info , b , off , local_requested ) ; off += local_requested ; len -= local_requested ; synchronized ( lock ) { requested -= local_requested ; } } else { manager . sendTransmit ( info , b , off , len ) ; synchronized ( lock ) { requested -= len ; } break ; } } }
write a subarray of bytes over connection .
