OioDatagramChannel channel, ChannelFuture future,
Object message, SocketAddress remoteAddress) {
try {
ChannelBuffer buf = (ChannelBuffer) message;
int offset = buf.readerIndex();
int length = buf.readableBytes();
ByteBuffer nioBuf = buf.toByteBuffer();
DatagramPacket packet;
if (nioBuf.hasArray()) {
// Avoid copy if the buffer is backed by an array.
packet = new DatagramPacket(