/** * 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 */ public boolean hasMessagePending() throws IOException { return pg_input.available() > 0 || connection.getInputStream().available() > 0; }
/** * 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 */ public boolean hasMessagePending() throws IOException { if (pg_input.available() > 0) { return true; } // In certain cases, available returns 0, yet there are bytes int soTimeout = getNetworkTimeout(); setNetworkTimeout(1); try { return pg_input.peek() != -1; } catch (SocketTimeoutException e) { return false; } finally { setNetworkTimeout(soTimeout); } }
/** * 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 */ public boolean hasMessagePending() throws IOException { return pg_input.available() > 0 || connection.getInputStream().available() > 0; }
/** * 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 */ public boolean hasMessagePending() throws IOException { return pg_input.available() > 0 || connection.getInputStream().available() > 0; }