/** * Closes the underlying SSLSocketChannel, which also will close the InputStream and the connection */ @Override public void close() throws IOException { channel.close(); } }
/** * Closes the underlying SSLSocketChannel, which will also close the OutputStream and connection */ @Override public void close() throws IOException { channel.close(); }
@Override public void close() throws IOException { sslSocketChannel.close(); }
private void writeFully(final ByteBuffer src) throws IOException { long lastByteWrittenTime = System.currentTimeMillis(); int bytesWritten = 0; while (src.hasRemaining()) { if (interrupted) { throw new TransmissionDisabledException(); } final int written = channel.write(src); bytesWritten += written; final long now = System.currentTimeMillis(); long sleepNanos = 1L; if (written > 0) { lastByteWrittenTime = now; } else { if (now > lastByteWrittenTime + timeoutMillis) { throw new SocketTimeoutException("Timed out writing to socket connected to " + hostname + ":" + port); } try { TimeUnit.NANOSECONDS.sleep(sleepNanos); } catch (final InterruptedException e) { close(); Thread.currentThread().interrupt(); // set the interrupt status throw new ClosedByInterruptException(); } sleepNanos = Math.min(sleepNanos * 2, BUFFER_FULL_EMPTY_WAIT_NANOS); } } logger.trace("{} Wrote {} bytes", this, bytesWritten); }
private int readData(final ByteBuffer dest) throws IOException { final long startTime = System.currentTimeMillis(); while (true) { if (interrupted) { throw new TransmissionDisabledException(); } if (dest.remaining() == 0) { return 0; } final int readCount = channel.read(dest); long sleepNanos = 1L; if (readCount == 0) { if (System.currentTimeMillis() > startTime + timeoutMillis) { throw new SocketTimeoutException("Timed out reading from socket connected to " + hostname + ":" + port); } try { TimeUnit.NANOSECONDS.sleep(sleepNanos); } catch (InterruptedException e) { close(); Thread.currentThread().interrupt(); // set the interrupt status throw new ClosedByInterruptException(); } sleepNanos = Math.min(sleepNanos * 2, BUFFER_FULL_EMPTY_WAIT_NANOS); continue; } logger.trace("{} Read {} bytes", this, readCount); return readCount; } }
@Override public void close() throws IOException { IOException suppressed = null; try { request.consume(); } catch (final IOException ioe) { suppressed = ioe; } try { channel.close(); } catch (final IOException ioe) { if (suppressed != null) { ioe.addSuppressed(suppressed); } throw ioe; } if (suppressed != null) { throw suppressed; } }
/** * Closes the underlying SSLSocketChannel, which also will close the InputStream and the connection */ @Override public void close() throws IOException { channel.close(); } }
/** * Closes the underlying SSLSocketChannel, which will also close the OutputStream and connection */ @Override public void close() throws IOException { channel.close(); }
@Override public void close() throws IOException { sslSocketChannel.close(); }
private int readData(final ByteBuffer dest) throws IOException { final long startTime = System.currentTimeMillis(); while (true) { if (interrupted) { throw new TransmissionDisabledException(); } if (dest.remaining() == 0) { return 0; } final int readCount = channel.read(dest); long sleepNanos = 1L; if (readCount == 0) { if (System.currentTimeMillis() > startTime + timeoutMillis) { throw new SocketTimeoutException("Timed out reading from socket connected to " + hostname + ":" + port); } try { TimeUnit.NANOSECONDS.sleep(sleepNanos); } catch (InterruptedException e) { close(); Thread.currentThread().interrupt(); // set the interrupt status throw new ClosedByInterruptException(); } sleepNanos = Math.min(sleepNanos * 2, BUFFER_FULL_EMPTY_WAIT_NANOS); continue; } logger.trace("{} Read {} bytes", this, readCount); return readCount; } }
private void writeFully(final ByteBuffer src) throws IOException { long lastByteWrittenTime = System.currentTimeMillis(); int bytesWritten = 0; while (src.hasRemaining()) { if (interrupted) { throw new TransmissionDisabledException(); } final int written = channel.write(src); bytesWritten += written; final long now = System.currentTimeMillis(); long sleepNanos = 1L; if (written > 0) { lastByteWrittenTime = now; } else { if (now > lastByteWrittenTime + timeoutMillis) { throw new SocketTimeoutException("Timed out writing to socket connected to " + hostname + ":" + port); } try { TimeUnit.NANOSECONDS.sleep(sleepNanos); } catch (final InterruptedException e) { close(); Thread.currentThread().interrupt(); // set the interrupt status throw new ClosedByInterruptException(); } sleepNanos = Math.min(sleepNanos * 2, BUFFER_FULL_EMPTY_WAIT_NANOS); } } logger.trace("{} Wrote {} bytes", this, bytesWritten); }