/** * Set the underlying socket. */ public void setSocket(NioChannel socket) { this.socket = socket; socketReadBufferSize = socket.getBufHandler().getReadBuffer().capacity(); int bufLength = skipBlankLinesSize + headerBufferSize + socketReadBufferSize; if (buf == null || buf.length < bufLength) { buf = new byte[bufLength]; } }
@Override protected boolean hasMoreDataToFlush() { return (flipped && socket.getBufHandler().getWriteBuffer().remaining()>0) || (!flipped && socket.getBufHandler().getWriteBuffer().position() > 0); }
/** * Set the underlying socket. */ public void setSocket(NioChannel socket) { this.socket = socket; socketReadBufferSize = socket.getBufHandler().getReadBuffer().capacity(); int bufLength = skipBlankLinesSize + headerBufferSize + socketReadBufferSize; if (buf == null || buf.length < bufLength) { buf = new byte[bufLength]; } }
public NioSocketWrapper(NioChannel channel, NioEndpoint endpoint) { super(channel, endpoint); pool = endpoint.getSelectorPool(); socketBufferHandler = channel.getBufHandler(); }
@Override protected boolean doIsReady() throws IOException { ByteBuffer readBuffer = channel.getBufHandler().getReadBuffer(); if (readBuffer.remaining() > 0) { return true; } readBuffer.clear(); fillReadBuffer(false); boolean isReady = readBuffer.position() > 0; readBuffer.flip(); return isReady; }
/** * Send an acknowledgment. */ @Override public void sendAck() throws IOException { if (!committed) { //Socket.send(socket, Constants.ACK_BYTES, 0, Constants.ACK_BYTES.length) < 0 socket.getBufHandler() .getWriteBuffer().put(Constants.ACK_BYTES,0,Constants.ACK_BYTES.length); writeToSocket(socket.getBufHandler() .getWriteBuffer(),true,true); } }
/** * Send an acknowledgment. */ @Override public void sendAck() throws IOException { if (!committed) { //Socket.send(socket, Constants.ACK_BYTES, 0, Constants.ACK_BYTES.length) < 0 socket.getBufHandler() .getWriteBuffer().put(Constants.ACK_BYTES,0,Constants.ACK_BYTES.length); writeToSocket(socket.getBufHandler() .getWriteBuffer(),true,true); } }
/** * Send an acknowledgment. */ @Override public void sendAck() throws IOException { if (!committed) { //Socket.send(socket, Constants.ACK_BYTES, 0, Constants.ACK_BYTES.length) < 0 socket.getBufHandler() .getWriteBuffer().put(Constants.ACK_BYTES,0,Constants.ACK_BYTES.length); writeToSocket(socket.getBufHandler() .getWriteBuffer(),true,true); } }
/** * Send an acknoledgement. */ public void sendAck() throws IOException { if (!committed) { //Socket.send(socket, Constants.ACK_BYTES, 0, Constants.ACK_BYTES.length) < 0 socket.getBufHandler() .getWriteBuffer().put(Constants.ACK_BYTES,0,Constants.ACK_BYTES.length); writeToSocket(socket.getBufHandler() .getWriteBuffer(),true,true); } }
/** * Recycle the output buffer. This should be called when closing the * connection. */ @Override public void recycle() { super.recycle(); if (socket != null) { socket.getBufHandler().getWriteBuffer().clear(); socket = null; } }
public NioServletOutputStream( SocketWrapper<NioChannel> wrapper, NioSelectorPool pool) { channel = wrapper.getSocket(); this.pool = pool; maxWrite = channel.getBufHandler().getWriteBuffer().capacity(); }
/** * Send an acknowledgment. */ @Override public void sendAck() throws IOException { if (!committed) { socket.getBufHandler().getWriteBuffer().put( Constants.ACK_BYTES, 0, Constants.ACK_BYTES.length); int result = writeToSocket(socket.getBufHandler().getWriteBuffer(), true, true); if (result < 0) { throw new IOException(sm.getString("iob.failedwrite.ack")); } } }
/** * Recycle the output buffer. This should be called when closing the * connection. */ @Override public void recycle() { super.recycle(); if (socket != null) { socket.getBufHandler().getWriteBuffer().clear(); socket = null; } flipped = false; }
public UpgradeNioProcessor(SocketWrapper<NioChannel> wrapper, UpgradeInbound upgradeInbound, NioSelectorPool pool) { super(upgradeInbound); wrapper.setTimeout(upgradeInbound.getReadTimeout()); this.nioChannel = wrapper.getSocket(); this.pool = pool; this.maxRead = nioChannel.getBufHandler().getReadBuffer().capacity(); this.maxWrite = nioChannel.getBufHandler().getWriteBuffer().capacity(); }
/** * Recycle the output buffer. This should be called when closing the * connection. */ @Override public void recycle() { super.recycle(); if (socket != null) { socket.getBufHandler().getWriteBuffer().clear(); socket = null; } lastWrite.set(1); }
/** * Recycle the output buffer. This should be called when closing the * connection. */ @Override public void recycle() { super.recycle(); if (socket != null) { socket.getBufHandler().getWriteBuffer().clear(); socket = null; } lastWrite.set(1); }
@Override protected void init(SocketWrapper<NioChannel> socketWrapper, AbstractEndpoint endpoint) throws IOException { socket = socketWrapper.getSocket(); socketReadBufferSize = socket.getBufHandler().getReadBuffer().capacity(); int bufLength = skipBlankLinesSize + headerBufferSize + socketReadBufferSize; if (buf == null || buf.length < bufLength) { buf = new byte[bufLength]; } pool = ((NioEndpoint)endpoint).getSelectorPool(); }
@Override protected void init(SocketWrapper<NioChannel> socketWrapper, AbstractEndpoint endpoint) throws IOException { socket = socketWrapper.getSocket(); socketReadBufferSize = socket.getBufHandler().getReadBuffer().capacity(); int bufLength = headerBufferSize + socketReadBufferSize; if (buf == null || buf.length < bufLength) { buf = new byte[bufLength]; } pool = ((NioEndpoint)endpoint).getSelectorPool(); }
/** * Callback to write data from the buffer. */ protected void flushBuffer() throws IOException { //prevent timeout for async, SelectionKey key = socket.getIOChannel().keyFor(socket.getPoller().getSelector()); if (key != null) { NioEndpoint.KeyAttachment attach = (NioEndpoint.KeyAttachment) key.attachment(); attach.access(); } //write to the socket, if there is anything to write if (socket.getBufHandler().getWriteBuffer().position() > 0) { socket.getBufHandler().getWriteBuffer().flip(); writeToSocket(socket.getBufHandler().getWriteBuffer(),true, false); } }
@Override protected void init(SocketWrapper<NioChannel> socketWrapper, AbstractEndpoint<NioChannel> endpoint) throws IOException { socket = socketWrapper.getSocket(); if (socket == null) { // Socket has been closed in another thread throw new IOException(sm.getString("iib.socketClosed")); } socketReadBufferSize = socket.getBufHandler().getReadBuffer().capacity(); int bufLength = headerBufferSize + socketReadBufferSize; if (buf == null || buf.length < bufLength) { buf = new byte[bufLength]; } pool = ((NioEndpoint)endpoint).getSelectorPool(); }