public boolean isDataAvailable(int timeout) throws IOException { boolean result = hasBufferedData(); if (!result) { int oldtimeout = this.socket.getSoTimeout(); try { this.socket.setSoTimeout(timeout); fillBuffer(); result = hasBufferedData(); } catch (InterruptedIOException e) { if (!(e instanceof SocketTimeoutException)) { throw e; } } finally { socket.setSoTimeout(oldtimeout); } } return result; }
/** * Returns true if the connection is probably functional. It's insufficient * to rely on isDataAvailable() returning normally; that approach cannot * distinguish between an exhausted stream and a stream with zero bytes * buffered. * * @hide */ public boolean isStale() throws IOException { if (hasBufferedData()) { return false; } int oldTimeout = this.socket.getSoTimeout(); try { this.socket.setSoTimeout(1); return fillBuffer() == -1; } catch (SocketTimeoutException e) { return false; // the connection is not stale; hooray } catch (IOException e) { return true; // the connection is stale, the read or soTimeout failed. } finally { this.socket.setSoTimeout(oldTimeout); } } // END android-added
public boolean isDataAvailable(final int timeout) throws IOException { boolean result = hasBufferedData(); if (!result) { final int oldtimeout = this.socket.getSoTimeout(); try { this.socket.setSoTimeout(timeout); fillBuffer(); result = hasBufferedData(); } finally { socket.setSoTimeout(oldtimeout); } } return result; }
public boolean isDataAvailable(final int timeout) throws IOException { boolean result = hasBufferedData(); if (!result) { final int oldtimeout = this.socket.getSoTimeout(); try { this.socket.setSoTimeout(timeout); fillBuffer(); result = hasBufferedData(); } finally { socket.setSoTimeout(oldtimeout); } } return result; }
public boolean isDataAvailable(final int timeout) throws IOException { boolean result = hasBufferedData(); if (!result) { final int oldtimeout = this.socket.getSoTimeout(); try { this.socket.setSoTimeout(timeout); fillBuffer(); result = hasBufferedData(); } finally { socket.setSoTimeout(oldtimeout); } } return result; }
public boolean isDataAvailable(final int timeout) throws IOException { boolean result = hasBufferedData(); if (!result) { final int oldtimeout = this.socket.getSoTimeout(); try { this.socket.setSoTimeout(timeout); fillBuffer(); result = hasBufferedData(); } finally { socket.setSoTimeout(oldtimeout); } } return result; }
@Override public boolean isDataAvailable(final int timeout) throws IOException { boolean result = hasBufferedData(); if (!result) { final int oldtimeout = this.socket.getSoTimeout(); try { this.socket.setSoTimeout(timeout); fillBuffer(); result = hasBufferedData(); } finally { socket.setSoTimeout(oldtimeout); } } return result; }
public boolean isDataAvailable(int timeout) throws IOException { boolean result = hasBufferedData(); if (!result) { int oldtimeout = this.socket.getSoTimeout(); try { this.socket.setSoTimeout(timeout); fillBuffer(); result = hasBufferedData(); } catch (InterruptedIOException e) { if (!(e instanceof SocketTimeoutException)) { throw e; } } finally { socket.setSoTimeout(oldtimeout); } } return result; }
public boolean isDataAvailable(int timeout) throws IOException { boolean result = hasBufferedData(); if (!result) { int oldtimeout = this.socket.getSoTimeout(); try { this.socket.setSoTimeout(timeout); fillBuffer(); result = hasBufferedData(); } catch (InterruptedIOException e) { if (!(e instanceof SocketTimeoutException)) { throw e; } } finally { socket.setSoTimeout(oldtimeout); } } return result; }
public boolean isDataAvailable(int timeout) throws IOException { boolean result = hasBufferedData(); if (!result) { int oldtimeout = this.socket.getSoTimeout(); try { this.socket.setSoTimeout(timeout); fillBuffer(); result = hasBufferedData(); } catch (InterruptedIOException e) { if (!(e instanceof SocketTimeoutException)) { throw e; } } finally { socket.setSoTimeout(oldtimeout); } } return result; }
public boolean isDataAvailable(int timeout) throws IOException { boolean result = hasBufferedData(); if (!result) { int oldtimeout = this.socket.getSoTimeout(); try { this.socket.setSoTimeout(timeout); fillBuffer(); result = hasBufferedData(); } catch (InterruptedIOException e) { if (!(e instanceof SocketTimeoutException)) { throw e; } } finally { socket.setSoTimeout(oldtimeout); } } return result; }
/** * Returns true if the connection is probably functional. It's insufficient * to rely on isDataAvailable() returning normally; that approach cannot * distinguish between an exhausted stream and a stream with zero bytes * buffered. * * @hide */ public boolean isStale() throws IOException { if (hasBufferedData()) { return false; } int oldTimeout = this.socket.getSoTimeout(); try { this.socket.setSoTimeout(1); return fillBuffer() == -1; } catch (SocketTimeoutException e) { return false; // the connection is not stale; hooray } catch (IOException e) { return true; // the connection is stale, the read or soTimeout failed. } finally { this.socket.setSoTimeout(oldTimeout); } } // END android-added
/** * Returns true if the connection is probably functional. It's insufficient * to rely on isDataAvailable() returning normally; that approach cannot * distinguish between an exhausted stream and a stream with zero bytes * buffered. * * @hide */ public boolean isStale() throws IOException { if (hasBufferedData()) { return false; } int oldTimeout = this.socket.getSoTimeout(); try { this.socket.setSoTimeout(1); return fillBuffer() == -1; } catch (SocketTimeoutException e) { return false; // the connection is not stale; hooray } catch (IOException e) { return true; // the connection is stale, the read or soTimeout failed. } finally { this.socket.setSoTimeout(oldTimeout); } } // END android-added
/** * Returns true if the connection is probably functional. It's insufficient * to rely on isDataAvailable() returning normally; that approach cannot * distinguish between an exhausted stream and a stream with zero bytes * buffered. * * @hide */ public boolean isStale() throws IOException { if (hasBufferedData()) { return false; } int oldTimeout = this.socket.getSoTimeout(); try { this.socket.setSoTimeout(1); return fillBuffer() == -1; } catch (SocketTimeoutException e) { return false; // the connection is not stale; hooray } catch (IOException e) { return true; // the connection is stale, the read or soTimeout failed. } finally { this.socket.setSoTimeout(oldTimeout); } } // END android-added
/** * Returns true if the connection is probably functional. It's insufficient * to rely on isDataAvailable() returning normally; that approach cannot * distinguish between an exhausted stream and a stream with zero bytes * buffered. * * @hide */ public boolean isStale() throws IOException { if (hasBufferedData()) { return false; } int oldTimeout = this.socket.getSoTimeout(); try { this.socket.setSoTimeout(1); return fillBuffer() == -1; } catch (SocketTimeoutException e) { return false; // the connection is not stale; hooray } catch (IOException e) { return true; // the connection is stale, the read or soTimeout failed. } finally { this.socket.setSoTimeout(oldTimeout); } } // END android-added