"Linux Network Programming" byte order and address reload

Source: Internet
Author: User

(3) byte order
<1> Big endian byte order
The highest significant bit is stored at the lowest memory address, and the least significant bit is stored at the highest memory address.
<2> Small-endian byte order
The highest significant bit is stored at the highest memory address, and the least significant bit is stored at the lowest memory address.
Save 0x12345678
-----------------> The direction of memory address growth
12 34 56 78 big endian byte order
78 56 34 12 small-endian byte-order
<3> Host byte order
Different hosts have different byte-order, such as x86 is the small-endian byte-order, ARM is configurable byte-order
<4> Network byte order
network byte order defined as big endian byte order
<5> byte-Order conversion functions
uint32_t htonl (uint32_t hostlong);
uint16_t htons (uint16_t hostshort);
uint32_t Ntohl (uint32_t netlong);
uint16_t Ntohs (uint32_t netlong);
<6> Address Conversion functions
#incldue <netinet/in.h>
#include <arpa/inet.h>

int Inet_aton (const char *pc, struct in_addr *inp); Convert dotted decimal to address structure
in_addr_t inet_addr (const char *pc); Convert dotted decimal to 32-bit integers
Char *inet_ntoa (struct in_addr in); Converts an address structure to a dotted-decimal IP address

"Linux Network Programming" byte order and address reload

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.