About the address translation of SOCKET address structure

The structure of the SOCKET address structure is sockaddr_in, where sin_addr is about the address of the SOCKET, and the substructure s_addr of sin_addr is related to the IP address, which is a word, that is, a variable in a similar form to 0x123AAAAA. The IP address can be converted into this form by inet_addr("192.168.1.1").
The IP address is composed of 4 bytes, that is, composed of 4 numbers from 0 to 255, and is stored in reverse order when stored.
Use inet_ntoa() to convert a variable in the form of 0x123AAAAA into an array, the first 4 digits of which are the digits of the IP address, and the return value of this function is a char pointer.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324731968&siteId=291194637