/** * 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); } }
/** * 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")); } } }
/** * 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); } }
/** * Callback to write data from the buffer. */ private 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); } }
/** * Callback to write data from the buffer. */ private 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); } }
/** * 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); } }
writeToSocket(socket.getBufHandler().getWriteBuffer(),block, !flipped); bufIter.remove(); writeToSocket(socket.getBufHandler().getWriteBuffer(),block, true);
private synchronized void addToBB(byte[] buf, int offset, int length) throws IOException { if (length == 0) return; // Try to flush any data in the socket's write buffer first boolean dataLeft = flushBuffer(isBlocking()); // Keep writing until all the data is written or a non-blocking write // leaves data in the buffer while (!dataLeft && length > 0) { int thisTime = transfer(buf,offset,length,socket.getBufHandler().getWriteBuffer()); length = length - thisTime; offset = offset + thisTime; int written = writeToSocket(socket.getBufHandler().getWriteBuffer(), isBlocking(), true); if (written == 0) { dataLeft = true; } else { dataLeft = flushBuffer(isBlocking()); } } NioEndpoint.KeyAttachment ka = (NioEndpoint.KeyAttachment)socket.getAttachment(false); if (ka != null) ka.access();//prevent timeouts for just doing client writes if (!isBlocking() && length > 0) { // Remaining data must be buffered addToBuffers(buf, offset, length); } }