code: public boolean hasMessagePending() throws IOException {
      if (pgInput.available() > 0) {
        return true;
      }
      // In certain cases, available returns 0, yet there are bytes
      long now = System.currentTimeMillis();
      if (now < nextStreamAvailableCheckTime && minStreamAvailableCheckDelay != 0) {
        // Do not use ".peek" too often
        return false;
      }
      nextStreamAvailableCheckTime = now + minStreamAvailableCheckDelay;
      int soTimeout = getNetworkTimeout();
      setNetworkTimeout(1);
      try {
        return pgInput.peek() != -1;
      } catch (SocketTimeoutException e) {
        return false;
      } finally {
        setNetworkTimeout(soTimeout);
      }
    }
docs: Check for pending backend messages without blocking. Might return false when there actually are
  messages waiting, depending on the characteristics of the underlying socket. This is used to
  detect asynchronous notifies from the backend, when available.
  
  @return true if there is a pending backend message
  @throws IOException if something wrong happens