Linux operating system network programming common structure

  

truct in_addr {

unsigned long s_addr; //that’sa 32-bit long, or 4 bytes

};

view plainprint?

struct sockaddr {

unsigned short sa_family; //address family, AF_xxx

char sa_data[14]; //14 bytes of protocol address

};

view plainprint?

struct sockaddr_in {

short int sin_family; //Address family

unsigned short int sin_port; //Port number

struct in_addr sin_addr; //Internet address

unsigned char sin_zero[8]; //Same size as struct sockaddr

};

view plainprint?

#define h_addr h_addr_list[0] /* The first address in h-addr-list*/

view plainprint?

struct hostent {

char *h_name; /* The official domain name of the host */

char **h_aliases; /* A host alias array ending in NULL */

int h_addrtype; /* The type of address returned, In the Internet environment is AF-INET */

int h_length; /* Byte length of address */

char **h_addr_list; /* An array ending in 0, including this All addresses of the host*/
zh-CN"],null,[0.93521482],zh-CN"]]]

Copyright © Windows knowledge All Rights Reserved