netty read part of the messages when the client write 1 command/ms ?
Christian Migowski
chrismfwrd at gmail.com
Tue Jun 1 04:23:25 EDT 2010
Hi,
this is called "packet fragmentation" and should be expected (i.e. it
is normal TCP behaviour and not a Netty bug). Trustin did write some
very good documentation about this in the Javadoc,
see here:
http://docs.jboss.org/netty/3.1/api/org/jboss/netty/handler/codec/frame/FrameDecoder.html
regards,
christian!
On Mon, May 31, 2010 at 4:41 PM, MCYang <zjuyyl at gmail.com> wrote:
>
> I try to bechmark my socket app.
> client do
>
> setInterval the follow command to 1ms
>
> socket.writeInt(bytes.length);
> socket.writeBytes(bytes);
> socket.flush();
>
>
> server do
>
> decode
> ChannelBuffer bf = (ChannelBuffer)buffer;
> int remaining = bf.readableBytes();
> int total = remaining;
> while(remaining>=4){
> len = bf.getInt(total-remaining);
> remaining = remaining-4;
> if(remaining>=len){
> bt = new byte[len];
> bf.getBytes(total-remaining, bt);
> remaining = remaining-len;
> }else {//here remaining<len,it means that some message isn't in this
> channelBuffer but int the next ChannelBuffer, is it a bug,or how can I fix
> it in this situation?
>
> bt = new byte[len];
> bf.getBytes(total-remaining, bt,0,remaining);
> break;
> }
>
> }
> --
> View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/netty-read-part-of-the-messages-when-the-client-write-1-command-ms-tp5122037p5122037.html
> Sent from the Netty User Group mailing list archive at Nabble.com.
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
>
More information about the netty-users
mailing list