code: @Override
    public int read(byte []buf, int offset, int length) throws IOException
    {
      try {
        if (_channel == null) {
          return -1;
        }
        
        int remaining = _readBuffer.remaining();
        
        if (remaining > 0) {
          _readBuffer.get(buf, offset, remaining);
        
          return remaining;
        }
        
        _readBuffer.clear();
        
        int channelRead = _channel.read(_readBuffer);
        _readBuffer.flip();
        
        if (channelRead < 0)
          return -1;
        
        _readBuffer.get(buf, offset, channelRead);
        
        return channelRead;
      } catch (InterruptedIOException e) {
        if (_throwReadInterrupts)
          throw e;
        
        log.log(Level.FINEST, e.toString(), e);
      } catch (IOException e) {
        if (_throwReadInterrupts)
          throw e;
  
        log.log(Level.FINER, e.toString(), e);
        // server/0611
        /*
        try {
          close();
        } catch (IOException e1) {
        }
        */
      }
  
      return -1;
    }
docs: Reads bytes from the socket.
  
  @param buf byte buffer receiving the bytes
  @param offset offset into the buffer
  @param length number of bytes to read
  @return number of bytes read or -1
  @exception throws ClientDisconnectException if the connection is dropped