X86 platform-based PC sends a byte order of an int (32-bit) integer over the network

Source: Internet
Author: User

1. Byte order

Byte order refers to the order in memory of data that occupies more than one byte of memory, usually with a small, big-endian byte order. Small-endian byte-order refers to low-byte data stored at low memory address, high-byte data stored at high memory address; Big endian byte order is high-byte data is stored at low address, low-byte data is stored at high address. when reading data from a computer, it is from high address to low address, while storing data in the opposite direction!

2. Host byte order to network byte order

The PC based on X86 platform is small endian, while some embedded platforms are byte order. As a result, more than 1 bytes of data such as int, uint16, UInt32, etc., should be changed in the storage order on these embedded platforms. In general, we believe that the sequence of bytes transmitted in the air is the standard order of the network byte order, taking into account the consistency with the protocol and interoperability with other platform products, when the packet is sent in the program, the host byte order is converted to the network byte order, and the packet is converted to the host byte order by the receiving packet.

3. Network byte order

Network byte order is a well-defined data representation format in TCP/IP, which is independent of the specific CPU type, operating system and so on, so that the data can be interpreted correctly when transferring between different hosts. The network byte order is sorted by the big endian (endian mode) .

4. Example diagram:

X86 platform-based PC sends a byte order of an int (32-bit) integer over the network

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.