@Override public int read(byte[] buf,int offset,int length) throws IOException {
  try {
    SocketChannel s=_s;
    if (s == null) {
      return -1;
    }
    int remaining=_readBuffer.remaining();
    if (remaining <= 0) {
      _readBuffer.clear();
      if (s.read(_readBuffer) < 0) {
        _readBuffer.flip();
        return -1;
      }
      _readBuffer.flip();
      remaining=_readBuffer.remaining();
    }
    int sublen=Math.min(remaining,length);
    _readBuffer.get(buf,offset,sublen);
    int readLength=sublen;
    if (readLength >= 0) {
      _totalReadBytes+=readLength;
    }
    return readLength;
  }
 catch (  InterruptedIOException e) {
    if (_throwReadInterrupts)     throw e;
    log.log(Level.FINEST,e.toString(),e);
  }
catch (  IOException e) {
    if (_throwReadInterrupts) {
      throw e;
    }
    if (log.isLoggable(Level.FINEST)) {
      log.log(Level.FINEST,e.toString(),e);
    }
 else {
      log.finer(e.toString());
    }
  }
  return -1;
}

@ Override public int read ( byte [ ] buf , int offset , int length ) throws IOException { try { SocketChannel s = _s ; if ( s == null ) { return - 1 ; } int remaining = _readBuffer . remaining ( ) ; if ( remaining <= 0 ) { _readBuffer . clear ( ) ; if ( s . read ( _readBuffer ) < 0 ) { _readBuffer . flip ( ) ; return - 1 ; } _readBuffer . flip ( ) ; remaining = _readBuffer . remaining ( ) ; } int sublen = Math . min ( remaining , length ) ; _readBuffer . get ( buf , offset , sublen ) ; int readLength = sublen ; if ( readLength >= 0 ) { _totalReadBytes += readLength ; } return readLength ; } catch ( InterruptedIOException e ) { if ( _throwReadInterrupts ) throw e ; log . log ( Level . FINEST , e . toString ( ) , e ) ; } catch ( IOException e ) { if ( _throwReadInterrupts ) { throw e ; } if ( log . isLoggable ( Level . FINEST ) ) { log . log ( Level . FINEST , e . toString ( ) , e ) ; } else { log . finer ( e . toString ( ) ) ; } } return - 1 ; }
reads bytes from the socket .
