Netty学习笔记
2022-09-14 19:46:30 0 举报
对应的博客专栏地址:https://blog.csdn.net/hotonyhui/category_12009990.html
作者其他创作
大纲/内容
容量:capacity=16
容量:capacity=9
buffer.writeBytes(new byte[]{6});此时已经不可写,所以需要扩容
...
可读字节:9
capacity(): 16maxCapacity(): 100readerIndex(): 10readableBytes(): 0isReadable(): falsewriterIndex(): 10writableBytes(): 6isWritable(): truemaxWritableBytes(): 90
可读字节:10
还可扩容91字节
写指针:writeIndex=4
容量:capacity
Netty专栏地址:https://blog.csdn.net/hotonyhui/category_12009990.html
capacity(): 9maxCapacity(): 100readerIndex(): 0readableBytes(): 9isReadable(): truewriterIndex(): 9writableBytes(): 0isWritable(): falsemaxWritableBytes(): 91
写指针:writeIndex=8
容量上限:maxCapacity=100
最大可写字节:91
读指针:readIndex=0
可读字节:8
写指针:writeIndex=10
最大可写字节:90
最大可写字节:92
capacity(): 9maxCapacity(): 100readerIndex(): 0readableBytes(): 8isReadable(): truewriterIndex(): 8writableBytes(): 1isWritable(): truemaxWritableBytes(): 92
读指针:readerIndex
写指针:writerIndex
最大可写字节:maxWritableBytes=96
capacity(): 9maxCapacity(): 100readerIndex(): 0readableBytes(): 0isReadable(): falsewriterIndex(): 0writableBytes(): 9isWritable(): truemaxWritableBytes(): 100
可读字节
写指针:writeIndex=10读指针:readIndex=10此时不可读了
废弃字节
写指针:writeIndex=0
可写字节: 1
写指针:writeIndex=9此时,已经不可写了
可写字节
可写字节: 9
ByteBuf结构
还可扩容多少字节
capacity(): 9maxCapacity(): 100readerIndex(): 0readableBytes(): 4isReadable(): truewriterIndex(): 4writableBytes(): 5isWritable(): truemaxWritableBytes(): 96
可读字节:4
可写字节: 5
buffer.writeInt(12);一个int类型表示4个Byte
可写字节:6
capacity(): 16maxCapacity(): 100readerIndex(): 0readableBytes(): 10isReadable(): truewriterIndex(): 10writableBytes(): 6isWritable(): truemaxWritableBytes(): 90
buffer.writeBytes(new byte[]{5});
容量上限:maxCapacity
byte[] dst = new byte[buffer.readableBytes()]; buffer.readBytes(dst);read方法会改变读指针
0 条评论
下一页