netty多线程通信一次传输较大数据遇到的问题

2025-05-23 14:25:04
推荐回答(1个)
回答1:

部分代码如下:
发送消息:
public static void sendMsg(ChannelHandlerContext ctx,byte[] bytes){
ByteBuf buf = ctx.alloc().buffer();
buf.writeInt(bytes.length);
buf.writeBytes(bytes);
ctx.writeAndFlush(buf);
}