Java Code Examples for com.sun.nio.sctp.MessageInfo#streamNumber()

The following examples show how to use com.sun.nio.sctp.MessageInfo#streamNumber() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SctpChannelImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private int send(int fd, ByteBuffer src, MessageInfo messageInfo)
        throws IOException {
    int streamNumber = messageInfo.streamNumber();
    SocketAddress target = messageInfo.address();
    boolean unordered = messageInfo.isUnordered();
    int ppid = messageInfo.payloadProtocolID();

    if (src instanceof DirectBuffer)
        return sendFromNativeBuffer(fd, src, target, streamNumber,
                unordered, ppid);

    /* Substitute a native buffer */
    int pos = src.position();
    int lim = src.limit();
    assert (pos <= lim && streamNumber >= 0);

    int rem = (pos <= lim ? lim - pos : 0);
    ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
    try {
        bb.put(src);
        bb.flip();
        /* Do not update src until we see how many bytes were written */
        src.position(pos);

        int n = sendFromNativeBuffer(fd, bb, target, streamNumber,
                unordered, ppid);
        if (n > 0) {
            /* now update src */
            src.position(pos + n);
        }
        return n;
    } finally {
        Util.releaseTemporaryDirectBuffer(bb);
    }
}
 
Example 2
Source File: SctpMultiChannelImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private int send(int fd,
                 ByteBuffer src,
                 int assocId,
                 SocketAddress target,
                 MessageInfo messageInfo)
        throws IOException {
    int streamNumber = messageInfo.streamNumber();
    boolean unordered = messageInfo.isUnordered();
    int ppid = messageInfo.payloadProtocolID();

    if (src instanceof DirectBuffer)
        return sendFromNativeBuffer(fd, src, target, assocId,
                streamNumber, unordered, ppid);

    /* Substitute a native buffer */
    int pos = src.position();
    int lim = src.limit();
    assert (pos <= lim && streamNumber >= 0);

    int rem = (pos <= lim ? lim - pos : 0);
    ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
    try {
        bb.put(src);
        bb.flip();
        /* Do not update src until we see how many bytes were written */
        src.position(pos);

        int n = sendFromNativeBuffer(fd, bb, target, assocId,
                streamNumber, unordered, ppid);
        if (n > 0) {
            /* now update src */
            src.position(pos + n);
        }
        return n;
    } finally {
        Util.releaseTemporaryDirectBuffer(bb);
    }
}
 
Example 3
Source File: SctpMessage.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
/**
 * Essential data that is being carried within SCTP Data Chunk
 * @param msgInfo       the {@link MessageInfo}
 * @param payloadBuffer channel buffer
 */
public SctpMessage(MessageInfo msgInfo, ByteBuf payloadBuffer) {
    super(payloadBuffer);
    if (msgInfo == null) {
        throw new NullPointerException("msgInfo");
    }
    this.msgInfo = msgInfo;
    streamIdentifier = msgInfo.streamNumber();
    protocolIdentifier = msgInfo.payloadProtocolID();
}
 
Example 4
Source File: AssociationImpl.java    From sctp with GNU Affero General Public License v3.0 5 votes vote down vote up
private PayloadData doReadSctp() throws IOException {

		rxBuffer.clear();
		MessageInfo messageInfo = this.socketChannelSctp.receive(rxBuffer, this, this.associationHandler);

		if (messageInfo == null) {
			if (logger.isDebugEnabled()) {
				logger.debug(String.format(" messageInfo is null for Association=%s", this.name));
			}
			return null;
		}

		int len = messageInfo.bytes();
		if (len == -1) {
			logger.error(String.format("Rx -1 while trying to read from underlying socket for Association=%s ",
					this.name));
			this.close();
			this.scheduleConnect();
			return null;
		}

		rxBuffer.flip();		
		ByteBuf byteBuf = Unpooled.copiedBuffer(rxBuffer);
		rxBuffer.clear();

		PayloadData payload = new PayloadData(len, byteBuf, messageInfo.isComplete(), messageInfo.isUnordered(),
				messageInfo.payloadProtocolID(), messageInfo.streamNumber());

		return payload;
	}
 
Example 5
Source File: SctpChannelImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private int send(int fd, ByteBuffer src, MessageInfo messageInfo)
        throws IOException {
    int streamNumber = messageInfo.streamNumber();
    SocketAddress target = messageInfo.address();
    boolean unordered = messageInfo.isUnordered();
    int ppid = messageInfo.payloadProtocolID();

    if (src instanceof DirectBuffer)
        return sendFromNativeBuffer(fd, src, target, streamNumber,
                unordered, ppid);

    /* Substitute a native buffer */
    int pos = src.position();
    int lim = src.limit();
    assert (pos <= lim && streamNumber >= 0);

    int rem = (pos <= lim ? lim - pos : 0);
    ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
    try {
        bb.put(src);
        bb.flip();
        /* Do not update src until we see how many bytes were written */
        src.position(pos);

        int n = sendFromNativeBuffer(fd, bb, target, streamNumber,
                unordered, ppid);
        if (n > 0) {
            /* now update src */
            src.position(pos + n);
        }
        return n;
    } finally {
        Util.releaseTemporaryDirectBuffer(bb);
    }
}
 
Example 6
Source File: SctpMultiChannelImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private int send(int fd,
                 ByteBuffer src,
                 int assocId,
                 SocketAddress target,
                 MessageInfo messageInfo)
        throws IOException {
    int streamNumber = messageInfo.streamNumber();
    boolean unordered = messageInfo.isUnordered();
    int ppid = messageInfo.payloadProtocolID();

    if (src instanceof DirectBuffer)
        return sendFromNativeBuffer(fd, src, target, assocId,
                streamNumber, unordered, ppid);

    /* Substitute a native buffer */
    int pos = src.position();
    int lim = src.limit();
    assert (pos <= lim && streamNumber >= 0);

    int rem = (pos <= lim ? lim - pos : 0);
    ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
    try {
        bb.put(src);
        bb.flip();
        /* Do not update src until we see how many bytes were written */
        src.position(pos);

        int n = sendFromNativeBuffer(fd, bb, target, assocId,
                streamNumber, unordered, ppid);
        if (n > 0) {
            /* now update src */
            src.position(pos + n);
        }
        return n;
    } finally {
        Util.releaseTemporaryDirectBuffer(bb);
    }
}
 
Example 7
Source File: SctpChannelImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private int send(int fd, ByteBuffer src, MessageInfo messageInfo)
        throws IOException {
    int streamNumber = messageInfo.streamNumber();
    SocketAddress target = messageInfo.address();
    boolean unordered = messageInfo.isUnordered();
    int ppid = messageInfo.payloadProtocolID();

    if (src instanceof DirectBuffer)
        return sendFromNativeBuffer(fd, src, target, streamNumber,
                unordered, ppid);

    /* Substitute a native buffer */
    int pos = src.position();
    int lim = src.limit();
    assert (pos <= lim && streamNumber >= 0);

    int rem = (pos <= lim ? lim - pos : 0);
    ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
    try {
        bb.put(src);
        bb.flip();
        /* Do not update src until we see how many bytes were written */
        src.position(pos);

        int n = sendFromNativeBuffer(fd, bb, target, streamNumber,
                unordered, ppid);
        if (n > 0) {
            /* now update src */
            src.position(pos + n);
        }
        return n;
    } finally {
        Util.releaseTemporaryDirectBuffer(bb);
    }
}
 
Example 8
Source File: SctpMultiChannelImpl.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private int send(int fd,
                 ByteBuffer src,
                 int assocId,
                 SocketAddress target,
                 MessageInfo messageInfo)
        throws IOException {
    int streamNumber = messageInfo.streamNumber();
    boolean unordered = messageInfo.isUnordered();
    int ppid = messageInfo.payloadProtocolID();

    if (src instanceof DirectBuffer)
        return sendFromNativeBuffer(fd, src, target, assocId,
                streamNumber, unordered, ppid);

    /* Substitute a native buffer */
    int pos = src.position();
    int lim = src.limit();
    assert (pos <= lim && streamNumber >= 0);

    int rem = (pos <= lim ? lim - pos : 0);
    ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
    try {
        bb.put(src);
        bb.flip();
        /* Do not update src until we see how many bytes were written */
        src.position(pos);

        int n = sendFromNativeBuffer(fd, bb, target, assocId,
                streamNumber, unordered, ppid);
        if (n > 0) {
            /* now update src */
            src.position(pos + n);
        }
        return n;
    } finally {
        Util.releaseTemporaryDirectBuffer(bb);
    }
}
 
Example 9
Source File: SctpChannelImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private int send(int fd, ByteBuffer src, MessageInfo messageInfo)
        throws IOException {
    int streamNumber = messageInfo.streamNumber();
    SocketAddress target = messageInfo.address();
    boolean unordered = messageInfo.isUnordered();
    int ppid = messageInfo.payloadProtocolID();

    if (src instanceof DirectBuffer)
        return sendFromNativeBuffer(fd, src, target, streamNumber,
                unordered, ppid);

    /* Substitute a native buffer */
    int pos = src.position();
    int lim = src.limit();
    assert (pos <= lim && streamNumber >= 0);

    int rem = (pos <= lim ? lim - pos : 0);
    ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
    try {
        bb.put(src);
        bb.flip();
        /* Do not update src until we see how many bytes were written */
        src.position(pos);

        int n = sendFromNativeBuffer(fd, bb, target, streamNumber,
                unordered, ppid);
        if (n > 0) {
            /* now update src */
            src.position(pos + n);
        }
        return n;
    } finally {
        Util.releaseTemporaryDirectBuffer(bb);
    }
}
 
Example 10
Source File: SctpMultiChannelImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private int send(int fd,
                 ByteBuffer src,
                 int assocId,
                 SocketAddress target,
                 MessageInfo messageInfo)
        throws IOException {
    int streamNumber = messageInfo.streamNumber();
    boolean unordered = messageInfo.isUnordered();
    int ppid = messageInfo.payloadProtocolID();

    if (src instanceof DirectBuffer)
        return sendFromNativeBuffer(fd, src, target, assocId,
                streamNumber, unordered, ppid);

    /* Substitute a native buffer */
    int pos = src.position();
    int lim = src.limit();
    assert (pos <= lim && streamNumber >= 0);

    int rem = (pos <= lim ? lim - pos : 0);
    ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
    try {
        bb.put(src);
        bb.flip();
        /* Do not update src until we see how many bytes were written */
        src.position(pos);

        int n = sendFromNativeBuffer(fd, bb, target, assocId,
                streamNumber, unordered, ppid);
        if (n > 0) {
            /* now update src */
            src.position(pos + n);
        }
        return n;
    } finally {
        Util.releaseTemporaryDirectBuffer(bb);
    }
}
 
Example 11
Source File: SctpMultiChannelImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private int send(int fd,
                 ByteBuffer src,
                 int assocId,
                 SocketAddress target,
                 MessageInfo messageInfo)
        throws IOException {
    int streamNumber = messageInfo.streamNumber();
    boolean unordered = messageInfo.isUnordered();
    int ppid = messageInfo.payloadProtocolID();

    if (src instanceof DirectBuffer)
        return sendFromNativeBuffer(fd, src, target, assocId,
                streamNumber, unordered, ppid);

    /* Substitute a native buffer */
    int pos = src.position();
    int lim = src.limit();
    assert (pos <= lim && streamNumber >= 0);

    int rem = (pos <= lim ? lim - pos : 0);
    ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
    try {
        bb.put(src);
        bb.flip();
        /* Do not update src until we see how many bytes were written */
        src.position(pos);

        int n = sendFromNativeBuffer(fd, bb, target, assocId,
                streamNumber, unordered, ppid);
        if (n > 0) {
            /* now update src */
            src.position(pos + n);
        }
        return n;
    } finally {
        Util.releaseTemporaryDirectBuffer(bb);
    }
}
 
Example 12
Source File: SctpMultiChannelImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private int send(int fd,
                 ByteBuffer src,
                 int assocId,
                 SocketAddress target,
                 MessageInfo messageInfo)
        throws IOException {
    int streamNumber = messageInfo.streamNumber();
    boolean unordered = messageInfo.isUnordered();
    int ppid = messageInfo.payloadProtocolID();

    if (src instanceof DirectBuffer)
        return sendFromNativeBuffer(fd, src, target, assocId,
                streamNumber, unordered, ppid);

    /* Substitute a native buffer */
    int pos = src.position();
    int lim = src.limit();
    assert (pos <= lim && streamNumber >= 0);

    int rem = (pos <= lim ? lim - pos : 0);
    ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
    try {
        bb.put(src);
        bb.flip();
        /* Do not update src until we see how many bytes were written */
        src.position(pos);

        int n = sendFromNativeBuffer(fd, bb, target, assocId,
                streamNumber, unordered, ppid);
        if (n > 0) {
            /* now update src */
            src.position(pos + n);
        }
        return n;
    } finally {
        Util.releaseTemporaryDirectBuffer(bb);
    }
}
 
Example 13
Source File: SctpChannelImpl.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private int send(int fd, ByteBuffer src, MessageInfo messageInfo)
        throws IOException {
    int streamNumber = messageInfo.streamNumber();
    SocketAddress target = messageInfo.address();
    boolean unordered = messageInfo.isUnordered();
    int ppid = messageInfo.payloadProtocolID();

    if (src instanceof DirectBuffer)
        return sendFromNativeBuffer(fd, src, target, streamNumber,
                unordered, ppid);

    /* Substitute a native buffer */
    int pos = src.position();
    int lim = src.limit();
    assert (pos <= lim && streamNumber >= 0);

    int rem = (pos <= lim ? lim - pos : 0);
    ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
    try {
        bb.put(src);
        bb.flip();
        /* Do not update src until we see how many bytes were written */
        src.position(pos);

        int n = sendFromNativeBuffer(fd, bb, target, streamNumber,
                unordered, ppid);
        if (n > 0) {
            /* now update src */
            src.position(pos + n);
        }
        return n;
    } finally {
        Util.releaseTemporaryDirectBuffer(bb);
    }
}
 
Example 14
Source File: SctpMultiChannelImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private int send(int fd,
                 ByteBuffer src,
                 int assocId,
                 SocketAddress target,
                 MessageInfo messageInfo)
        throws IOException {
    int streamNumber = messageInfo.streamNumber();
    boolean unordered = messageInfo.isUnordered();
    int ppid = messageInfo.payloadProtocolID();

    if (src instanceof DirectBuffer)
        return sendFromNativeBuffer(fd, src, target, assocId,
                streamNumber, unordered, ppid);

    /* Substitute a native buffer */
    int pos = src.position();
    int lim = src.limit();
    assert (pos <= lim && streamNumber >= 0);

    int rem = (pos <= lim ? lim - pos : 0);
    ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
    try {
        bb.put(src);
        bb.flip();
        /* Do not update src until we see how many bytes were written */
        src.position(pos);

        int n = sendFromNativeBuffer(fd, bb, target, assocId,
                streamNumber, unordered, ppid);
        if (n > 0) {
            /* now update src */
            src.position(pos + n);
        }
        return n;
    } finally {
        Util.releaseTemporaryDirectBuffer(bb);
    }
}
 
Example 15
Source File: SctpChannelImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private int send(int fd, ByteBuffer src, MessageInfo messageInfo)
        throws IOException {
    int streamNumber = messageInfo.streamNumber();
    SocketAddress target = messageInfo.address();
    boolean unordered = messageInfo.isUnordered();
    int ppid = messageInfo.payloadProtocolID();

    if (src instanceof DirectBuffer)
        return sendFromNativeBuffer(fd, src, target, streamNumber,
                unordered, ppid);

    /* Substitute a native buffer */
    int pos = src.position();
    int lim = src.limit();
    assert (pos <= lim && streamNumber >= 0);

    int rem = (pos <= lim ? lim - pos : 0);
    ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
    try {
        bb.put(src);
        bb.flip();
        /* Do not update src until we see how many bytes were written */
        src.position(pos);

        int n = sendFromNativeBuffer(fd, bb, target, streamNumber,
                unordered, ppid);
        if (n > 0) {
            /* now update src */
            src.position(pos + n);
        }
        return n;
    } finally {
        Util.releaseTemporaryDirectBuffer(bb);
    }
}
 
Example 16
Source File: SctpMultiChannelImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private int send(int fd,
                 ByteBuffer src,
                 int assocId,
                 SocketAddress target,
                 MessageInfo messageInfo)
        throws IOException {
    int streamNumber = messageInfo.streamNumber();
    boolean unordered = messageInfo.isUnordered();
    int ppid = messageInfo.payloadProtocolID();

    if (src instanceof DirectBuffer)
        return sendFromNativeBuffer(fd, src, target, assocId,
                streamNumber, unordered, ppid);

    /* Substitute a native buffer */
    int pos = src.position();
    int lim = src.limit();
    assert (pos <= lim && streamNumber >= 0);

    int rem = (pos <= lim ? lim - pos : 0);
    ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
    try {
        bb.put(src);
        bb.flip();
        /* Do not update src until we see how many bytes were written */
        src.position(pos);

        int n = sendFromNativeBuffer(fd, bb, target, assocId,
                streamNumber, unordered, ppid);
        if (n > 0) {
            /* now update src */
            src.position(pos + n);
        }
        return n;
    } finally {
        Util.releaseTemporaryDirectBuffer(bb);
    }
}
 
Example 17
Source File: NioSctpChannel.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean doWriteMessage(Object msg, ChannelOutboundBuffer in) throws Exception {
    SctpMessage packet = (SctpMessage) msg;
    ByteBuf data = packet.content();
    int dataLen = data.readableBytes();
    if (dataLen == 0) {
        return true;
    }

    ByteBufAllocator alloc = alloc();
    boolean needsCopy = data.nioBufferCount() != 1;
    if (!needsCopy) {
        if (!data.isDirect() && alloc.isDirectBufferPooled()) {
            needsCopy = true;
        }
    }
    ByteBuffer nioData;
    if (!needsCopy) {
        nioData = data.nioBuffer();
    } else {
        data = alloc.directBuffer(dataLen).writeBytes(data);
        nioData = data.nioBuffer();
    }
    final MessageInfo mi = MessageInfo.createOutgoing(association(), null, packet.streamIdentifier());
    mi.payloadProtocolID(packet.protocolIdentifier());
    mi.streamNumber(packet.streamIdentifier());
    mi.unordered(packet.isUnordered());

    final int writtenBytes = javaChannel().send(nioData, mi);
    return writtenBytes > 0;
}
 
Example 18
Source File: SctpChannelImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private int send(int fd, ByteBuffer src, MessageInfo messageInfo)
        throws IOException {
    int streamNumber = messageInfo.streamNumber();
    SocketAddress target = messageInfo.address();
    boolean unordered = messageInfo.isUnordered();
    int ppid = messageInfo.payloadProtocolID();

    if (src instanceof DirectBuffer)
        return sendFromNativeBuffer(fd, src, target, streamNumber,
                unordered, ppid);

    /* Substitute a native buffer */
    int pos = src.position();
    int lim = src.limit();
    assert (pos <= lim && streamNumber >= 0);

    int rem = (pos <= lim ? lim - pos : 0);
    ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
    try {
        bb.put(src);
        bb.flip();
        /* Do not update src until we see how many bytes were written */
        src.position(pos);

        int n = sendFromNativeBuffer(fd, bb, target, streamNumber,
                unordered, ppid);
        if (n > 0) {
            /* now update src */
            src.position(pos + n);
        }
        return n;
    } finally {
        Util.releaseTemporaryDirectBuffer(bb);
    }
}
 
Example 19
Source File: OioSctpChannel.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
@Override
protected void doWrite(ChannelOutboundBuffer in) throws Exception {
    if (!writeSelector.isOpen()) {
        return;
    }
    final int size = in.size();
    final int selectedKeys = writeSelector.select(SO_TIMEOUT);
    if (selectedKeys > 0) {
        final Set<SelectionKey> writableKeys = writeSelector.selectedKeys();
        if (writableKeys.isEmpty()) {
            return;
        }
        Iterator<SelectionKey> writableKeysIt = writableKeys.iterator();
        int written = 0;
        for (;;) {
            if (written == size) {
                // all written
                return;
            }
            writableKeysIt.next();
            writableKeysIt.remove();

            SctpMessage packet = (SctpMessage) in.current();
            if (packet == null) {
                return;
            }

            ByteBuf data = packet.content();
            int dataLen = data.readableBytes();
            ByteBuffer nioData;

            if (data.nioBufferCount() != -1) {
                nioData = data.nioBuffer();
            } else {
                nioData = ByteBuffer.allocate(dataLen);
                data.getBytes(data.readerIndex(), nioData);
                nioData.flip();
            }

            final MessageInfo mi = MessageInfo.createOutgoing(association(), null, packet.streamIdentifier());
            mi.payloadProtocolID(packet.protocolIdentifier());
            mi.streamNumber(packet.streamIdentifier());
            mi.unordered(packet.isUnordered());

            ch.send(nioData, mi);
            written ++;
            in.remove();

            if (!writableKeysIt.hasNext()) {
                return;
            }
        }
    }
}
 
Example 20
Source File: OioSctpChannel.java    From netty4.0.27Learn with Apache License 2.0 4 votes vote down vote up
@Override
protected void doWrite(ChannelOutboundBuffer in) throws Exception {
    if (!writeSelector.isOpen()) {
        return;
    }
    final int size = in.size();
    final int selectedKeys = writeSelector.select(SO_TIMEOUT);
    if (selectedKeys > 0) {
        final Set<SelectionKey> writableKeys = writeSelector.selectedKeys();
        if (writableKeys.isEmpty()) {
            return;
        }
        Iterator<SelectionKey> writableKeysIt = writableKeys.iterator();
        int written = 0;
        for (;;) {
            if (written == size) {
                // all written
                return;
            }
            writableKeysIt.next();
            writableKeysIt.remove();

            SctpMessage packet = (SctpMessage) in.current();
            if (packet == null) {
                return;
            }

            ByteBuf data = packet.content();
            int dataLen = data.readableBytes();
            ByteBuffer nioData;

            if (data.nioBufferCount() != -1) {
                nioData = data.nioBuffer();
            } else {
                nioData = ByteBuffer.allocate(dataLen);
                data.getBytes(data.readerIndex(), nioData);
                nioData.flip();
            }

            final MessageInfo mi = MessageInfo.createOutgoing(association(), null, packet.streamIdentifier());
            mi.payloadProtocolID(packet.protocolIdentifier());
            mi.streamNumber(packet.streamIdentifier());

            ch.send(nioData, mi);
            written ++;
            in.remove();

            if (!writableKeysIt.hasNext()) {
                return;
            }
        }
    }
}