public Nio2SocketWrapper(Nio2Channel channel, final Nio2Endpoint endpoint) { super(channel, endpoint); socketBufferHandler = channel.getBufHandler();
@Override protected void populateRemoteAddr() { SocketAddress socketAddress = null; try { socketAddress = getSocket().getIOChannel().getRemoteAddress(); } catch (IOException e) { // Ignore } if (socketAddress instanceof InetSocketAddress) { remoteAddr = ((InetSocketAddress) socketAddress).getAddress().getHostAddress(); } }
if (socketWrapper.getSocket().isHandshakeComplete()) { handshake = socketWrapper.getSocket().handshake(); if (running && !paused) { if (!nioChannels.push(socketWrapper.getSocket())) { socketWrapper.getSocket().free(); if (running && !paused) { if (!nioChannels.push(socketWrapper.getSocket())) { socketWrapper.getSocket().free();
getSocket().getBufHandler().configureWriteBufferForWrite(); ByteBuffer buffer = getSocket().getBufHandler().getWriteBuffer(); int nRead = -1; try { getSocket().getBufHandler().configureWriteBufferForRead(); Nio2Endpoint.startInline(); getSocket().write(buffer, toNio2Timeout(getWriteTimeout()), TimeUnit.MILLISECONDS, data, sendfileHandler); Nio2Endpoint.endInline();
public void awaitBytes() { // NO-OP is there is already a read in progress. if (readPending.tryAcquire()) { getSocket().getBufHandler().configureReadBufferForWrite(); Nio2Endpoint.startInline(); getSocket().read(getSocket().getBufHandler().getReadBuffer(), toNio2Timeout(getReadTimeout()), TimeUnit.MILLISECONDS, this, awaitBytesHandler); Nio2Endpoint.endInline(); } }
channel = new SecureNio2Channel(bufhandler, this); } else { channel = new Nio2Channel(bufhandler); channel.reset(socket, socketWrapper); socketWrapper.setReadTimeout(getConnectionTimeout()); socketWrapper.setWriteTimeout(getConnectionTimeout());
@Override public <A> void read(ByteBuffer dst, A attachment, CompletionHandler<Integer, ? super A> handler) { read(dst, 0L, TimeUnit.MILLISECONDS, attachment, handler); }
@Override public boolean isClosed() { return closed || !getSocket().isOpen(); }
@Override public void close() throws IOException { getSocket().close(); }
@Override public void run() { // Then close all active connections if any remain try { for (Nio2Channel channel : getHandler().getOpenSockets()) { closeSocket(channel.getSocket()); } } catch (Throwable t) { ExceptionUtils.handleThrowable(t); } finally { allClosed = true; } } });
@Override public void free() { super.free(); if (endpoint.getSocketProperties().getDirectSslBuffer()) { ByteBufferUtils.cleanDirectBuffer(netInBuffer); ByteBufferUtils.cleanDirectBuffer(netOutBuffer); } }
ByteBuffer buffer = getSocket().getBufHandler().getWriteBuffer(); if (!buffer.hasRemaining()) { if (attachment.length <= 0) { getSocket().getBufHandler().configureWriteBufferForWrite(); int nRead = -1; try { getSocket().getBufHandler().configureWriteBufferForRead(); if (attachment.length < buffer.remaining()) { buffer.limit(buffer.limit() - buffer.remaining() + (int) attachment.length); getSocket().write(buffer, toNio2Timeout(getWriteTimeout()), TimeUnit.MILLISECONDS, attachment, this);
@Override protected void populateRemoteHost() { SocketAddress socketAddress = null; try { socketAddress = getSocket().getIOChannel().getRemoteAddress(); } catch (IOException e) { log.warn(sm.getString("endpoint.warn.noRemoteHost", getSocket()), e); } if (socketAddress instanceof InetSocketAddress) { remoteHost = ((InetSocketAddress) socketAddress).getAddress().getHostName(); if (remoteAddr == null) { remoteAddr = ((InetSocketAddress) socketAddress).getAddress().getHostAddress(); } } }
getSocket().read(dsts, offset, length, timeout, unit, state, completion);
@Override protected void populateLocalAddr() { SocketAddress socketAddress = null; try { socketAddress = getSocket().getIOChannel().getLocalAddress(); } catch (IOException e) { log.warn(sm.getString("endpoint.warn.noLocalAddr", getSocket()), e); } if (socketAddress instanceof InetSocketAddress) { localAddr = ((InetSocketAddress) socketAddress).getAddress().getHostAddress(); } }
@Override protected void populateLocalPort() { SocketAddress socketAddress = null; try { socketAddress = getSocket().getIOChannel().getLocalAddress(); } catch (IOException e) { log.warn(sm.getString("endpoint.warn.noLocalPort", getSocket()), e); } if (socketAddress instanceof InetSocketAddress) { localPort = ((InetSocketAddress) socketAddress).getPort(); } }