ChannelBuffer.write*() changes the readable bytes
hezjing
hezjing at gmail.com
Wed Apr 1 09:03:39 EDT 2009
Hi
I think this is working correctly, and the API said readableBytes =
writerIndex - readerIndex.
So the solution is as simple as to mark the writerIndex before the
changes, and then restore writerIndex when done:
ChannelBuffer buffer = dynamicBuffer(512);
// write some bytes here
...
buffer.markWriterIndex();
System.out.println("readableBytes: " + buffer.readableBytes());
buffer.writerIndex(2);
// overwrite some bytes here
...
buffer.resetWriterIndex();
System.out.println("readableBytes: " + buffer.readableBytes());
On Wed, Apr 1, 2009 at 4:47 PM, hezjing <hezjing at gmail.com> wrote:
> Hi
> Is it normal that ChannelBuffer.write*() changes the readable bytes?
>
> For example:
>
> ChannelBuffer buffer = dynamicBuffer(512);
> // write some bytes here
> ...
> System.out.println("readableBytes: " + buffer.readableBytes());
> buffer.writerIndex(2);
> System.out.println("readableBytes: " + buffer.readableBytes());
>
> and the program printed:
>
> readableBytes: 27
> readableBytes: 2
>
>
> The readable bytes became 2 after the writerIndex() is called (it was 27).
>
>
> --
>
> Hez
>
--
Hez
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20090401/b3241b04/attachment.html
More information about the netty-users
mailing list