Byte order, divided into high in front and low in front, White is to start from the low operation or high-level operation
The byte order of Java and the network is consistent, both high and low, which means that Java side serialization and deserialization do not care about the problem of byte order,
The question is, what's the point of talking about byte order? That is, assuming C + + and Java communication, this time the C + + side need to consider the byte order, need to be serialized and deserialized when the flip
This is the method provided by Mina Iobuffer to set the byte order
Iobuffer order (Byteorder bo):
This method is set to Big Endian or little Endian,java in the default is big endian,c++ and other languages are generally little Endian.
This is a piece of code when Mina handles sticky and broken packets.
Buf.flip ();
Iobuffer newbuf = Iobuffer.allocate (
Buf.remaining () + in.remaining ()). Setautoexpand (True);
Newbuf.order (Buf.order ());
Newbuf.put (BUF);
Newbuf.put (in);
Newbuf.flip ();
BUF = Newbuf;
Update the session attribute.
Session.setattribute (BUFFER, buf);
Watch this.
We have a new iobuffer, which is not supported by default and does not specify byte order, so we are all explicitly set
Sets the byte order of the Newbuff to coincide with the session, overwriting the values in the session
Learn more about byte order reference http://www.blogjava.net/tinysun/archive/2009/12/31/307952.html
byte order knowledge