Nik*_*sov 3 java asynchronous bytebuffer netty
我正在使用在netty顶部实现的一些框架.我正在使用以下两个选项从客户端向服务器发送消息.我想这两个片段应该将相同的字节写入套接字,它在服务器端的行为是不同的.它有什么不同?
选项1:好的
ChannelBuffer buf = ChannelBuffers.buffer(1);
buf.writeByte(0x1c);
e.getChannel().write(buf);
Run Code Online (Sandbox Code Playgroud)
选项2:失败
ByteBuffer buf = ByteBuffer.allocate(1);
buf.put(0x1c);
e.getChannel().write(ChannelBuffers.wrappedBuffer(buf));
Run Code Online (Sandbox Code Playgroud)