UDP problem sending byte768 bytes
"이희승 (Trustin Lee)"
trustin at gmail.com
Fri Jun 26 12:32:26 EDT 2009
By the way, please let me know if you think the default (768) is not
sane and should be increased. I'm not really a UDP expert so other
people's suggestion is appreciated.
Thanks
이희승 (Trustin Lee) wrote:
> Hi Neil,
>
> It's because the default receiveBufferSizePredictor of DatagramChannel
> is FixedReceiveBufferSizePredictor(768). You can configure the channel
> to a FixedReceiveBufferSizePredictor with different payload size. For
> example:
>
> DatagramChannel ch = ...;
> ch.getConfig().setReceiveBufferSizePredictor(
> new FixedReceiveBufferSizePredictor(1024));
>
> or:
>
> ConnectionlessBootstrap b = ...;
> b.setOption("receiveBufferSizePredictor",
> new FixedReceiveBufferSizePredictor(1024));
>
> BTW, I wouldn't recommend to using AdaptiveReceiveBufferSizePrediector
> for datagrams.
>
> HTH,
> Trustin
>
> On 2009-06-25 오전 4:49, neilson9 wrote:
>> Hi,
>>
>> Im having a couple of problems sending UDP byte[]> 768K
>>
>> For example if Im passing 1024bytes the buffer.readIndex does not get
>> updated. The sender only passes 768 bytes and if I manually set the
>> readIndex to 768 it sends another 768 bytes on the second send. I would like
>> to iterate of the byte[] and use the offsets to prevent copying data etc.
>>
>> Any help appreciated.
>> Regards Neil.
>>
>> For example:
>> byte[] payload = userdata....;
>>
>> channel = (DatagramChannel) b.bind(new InetSocketAddress(0));
>> ChannelBuffer buffer = dynamicBuffer(bytes.length);
>> buffer.writeBytes(bytes);
>> LOGGER.info("Sending:" + bytes.length + " sent:" + buffer.readerIndex());
>> ChannelFuture channelFuture = channel.write(buffer, new
>> InetSocketAddress(uri.getHost(), port));
>> // manually setting to see if it sends the remainder
>> buffer.readerIndex(768);
>>
>> channelFuture = channel.write(buffer, new
>> InetSocketAddress(uri.getHost(), port));
>> LOGGER.info("Sending:" + buffer.readerIndex());
>>
>>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
--
Trustin Lee, http://gleamynode.net
More information about the netty-users
mailing list