code: public int read(byte []buffer, int offset, int length, long timeout)
      throws IOException
    {
      if (length == 0) {
        throw new IllegalArgumentException();
      }
  
      long requestExpireTime = _requestExpireTime;
  
      if (requestExpireTime > 0 && requestExpireTime < CurrentTime.currentTime()) {
        close();
        throw new ClientDisconnectException(L.l("{0}: request-timeout read",
                                                addressRemote()));
      }
  
      int result = 0;
  
      synchronized (_readLock) {
        long now = CurrentTime.getCurrentTimeActual();
  
        long expires;
  
        // gap is because getCurrentTimeActual() isn't exact
        long gap = 20;
  
        if (timeout >= 0)
          expires = timeout + now - gap;
        else
          expires = _socketTimeout + now - gap;
  
        do {
          result = readNative(_socketFd, buffer, offset, length, timeout);
  
          now = CurrentTime.getCurrentTimeActual();
  
          timeout = expires - now;
        } while (result == JniStream.TIMEOUT_EXN && timeout > 0);
      }
  
      return result;
    }
docs: Reads from the socket.