public int read(ByteBuffer dst) throws IOException {
  if (!dst.hasRemaining())   return 0;
  if (!isHandShakeComplete()) {
    if (isBlocking()) {
      while (!isHandShakeComplete()) {
        processHandshake();
      }
    }
 else {
      processHandshake();
      if (!isHandShakeComplete()) {
        return 0;
      }
    }
  }
  int purged=readRemaining(dst);
  if (purged != 0)   return purged;
  assert (inData.position() == 0);
  inData.clear();
  if (!inCrypt.hasRemaining())   inCrypt.clear();
 else   inCrypt.compact();
  if (isBlocking() || readEngineResult.getStatus() == Status.BUFFER_UNDERFLOW)   if (socketChannel.read(inCrypt) == -1) {
    return -1;
  }
  inCrypt.flip();
  unwrap();
  int transfered=transfereTo(inData,dst);
  if (transfered == 0 && isBlocking()) {
    return read(dst);
  }
  return transfered;
}

public int read ( ByteBuffer dst ) throws IOException { if ( ! dst . hasRemaining ( ) ) return 0 ; if ( ! isHandShakeComplete ( ) ) { if ( isBlocking ( ) ) { while ( ! isHandShakeComplete ( ) ) { processHandshake ( ) ; } } else { processHandshake ( ) ; if ( ! isHandShakeComplete ( ) ) { return 0 ; } } } int purged = readRemaining ( dst ) ; if ( purged != 0 ) return purged ; assert ( inData . position ( ) == 0 ) ; inData . clear ( ) ; if ( ! inCrypt . hasRemaining ( ) ) inCrypt . clear ( ) ; else inCrypt . compact ( ) ; if ( isBlocking ( ) || readEngineResult . getStatus ( ) == Status . BUFFER_UNDERFLOW ) if ( socketChannel . read ( inCrypt ) == - 1 ) { return - 1 ; } inCrypt . flip ( ) ; unwrap ( ) ; int transfered = transfereTo ( inData , dst ) ; if ( transfered == 0 && isBlocking ( ) ) { return read ( dst ) ; } return transfered ; }
blocks when in blocking mode until at least one byte has been decoded . < br > when not in blocking mode 0 may be returned .
