synchronized void receive(byte b[],int off,int len) throws IOException {
  checkStateForReceive();
  writeSide=Thread.currentThread();
  int bytesToTransfer=len;
  while (bytesToTransfer > 0) {
    if (in == out)     awaitSpace();
    int nextTransferAmount=0;
    if (out < in) {
      nextTransferAmount=buffer.length - in;
    }
 else     if (in < out) {
      if (in == -1) {
        in=out=0;
        nextTransferAmount=buffer.length - in;
      }
 else {
        nextTransferAmount=out - in;
      }
    }
    if (nextTransferAmount > bytesToTransfer)     nextTransferAmount=bytesToTransfer;
    assert (nextTransferAmount > 0);
    System.arraycopy(b,off,buffer,in,nextTransferAmount);
    bytesToTransfer-=nextTransferAmount;
    off+=nextTransferAmount;
    in+=nextTransferAmount;
    if (in >= buffer.length) {
      in=0;
    }
  }
}

synchronized void receive ( byte b [ ] , int off , int len ) throws IOException { checkStateForReceive ( ) ; writeSide = Thread . currentThread ( ) ; int bytesToTransfer = len ; while ( bytesToTransfer > 0 ) { if ( in == out ) awaitSpace ( ) ; int nextTransferAmount = 0 ; if ( out < in ) { nextTransferAmount = buffer . length - in ; } else if ( in < out ) { if ( in == - 1 ) { in = out = 0 ; nextTransferAmount = buffer . length - in ; } else { nextTransferAmount = out - in ; } } if ( nextTransferAmount > bytesToTransfer ) nextTransferAmount = bytesToTransfer ; assert ( nextTransferAmount > 0 ) ; System . arraycopy ( b , off , buffer , in , nextTransferAmount ) ; bytesToTransfer -= nextTransferAmount ; off += nextTransferAmount ; in += nextTransferAmount ; if ( in >= buffer . length ) { in = 0 ; } } }
receives data into an array of bytes . this method will block until some input is available .
