Linux sockets socket and addressing

Source: Internet
Author: User

Sockets need to be bundled on the address to be useful!

Identify the target process to have 1. The other computer's computer network address IP 2. Port number shows the specific process of the other machine

The sequence of bytes is the meaning of the order of bytes.

Detailed explanation can see this

Since network transport is the byte order of the specified big end, it is possible to transform the data in a small-endian environment.

These 4 functions are helpful:

#include <arpa/inet.h>

uint32_t htonl (unit32_t hostinit32); Represented by network byte order

unit16_t htons (unit16_t hostint16);

unit32_t Ntohl (unit32_t netint32); Represented by host byte order

unit16_t Ntohs (unit16_t netint16);

The address formats of different domains are different, so the addresses will be uniformly converted to the common address structure sockaddr!

Linux sockets socket and addressing

Related Article

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: 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.