The message is big endian, and the host takes the number in little endian order.

For example: 2 bytes length:

method one:

uchar ch[2] = {0x12,0x34};
usigned int lenght = ch[0]<<8 + ch[1];

Method Two:

uchar ch[2] = {0x12,0x34};
usigned int lenght = ntohs(ch);

Guess you like

Origin blog.csdn.net/modi000/article/details/123256154