1
我寫了一個netty服務器使用http://netty.io/wiki/user-guide-for-4.x.html鏈接。但是我只能獲得高達16384字節的數據。netty SimpleChannelInboundHandler消息接收只能達到16384
public class DiscardServerHandler extends ChannelInboundHandlerAdapter
{
byte bNullArray[] = "".getBytes();
String strFullData= new String(bNullArray,StandardCharsets.UTF_8);
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
{
try
{
String MsgRead;
ByteBuf in = (ByteBuf) msg;
MsgRead=in.toString(io.netty.util.CharsetUtil.UTF_8);
// here I get data only upto 1024 and this method get called 16 times.
// So total data received is == 1024*16 = 16384
strFullData = strFullData + MsgRead;
}
finally
{
ReferenceCountUtil.release(msg);
}
}
@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception
{
//WriteMyLog(strFullData);
//Here size of strFullData is 16384
strFullData = ProcessMyData(strFullData);
byte[] respByteBuf = strFullData.getBytes();
ByteBuf Resp1 = ctx.alloc().buffer(respByteBuf.length);
Resp1.writeBytes(respByteBuf);
ctx.write(Resp1);
ctx.flush();
ctx.close();
}
}
如何獲取更多數據?