UDP problem sending byte768 bytes

"이희승 (Trustin Lee)" trustin at gmail.com
Thu Jun 25 00:46:10 EDT 2009


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());
> 
> 


-- 
— Trustin Lee, http://gleamynode.net/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 259 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20090625/9c9638ae/attachment.bin 


More information about the netty-users mailing list