struct sockaddr {
sa_family_t sin_family;//地址族
char sa_data[14]; //14字节,包含套接字中的目标地址和端口信息
};
struct sockaddr_in {
sa_family_t sin_family;
uint16_t sin_port; //2字节
struct in_addr sin_addr; //4字节
char sin_zero[8];
};
struct in_addr {
In_addr_t s_addr;//32位IP地址
};
/*
The hostent structure is defined in <netdb.h> as follows:
struct hostent {
char *h_name; /* official name of host */
// char **h_aliases; /* alias list */
// int h_addrtype; /* host address type */
// int h_length; /* length of address */
// char **h_addr_list; /* list of addresses */
// }
// #define h_addr h_addr_list[0] /* for backward compatibility */
/*
The members of the hostent structure are:
h_name The official name of the host.
h_aliases
An array of alternative names for the host, terminated by a NULL
pointer.
h_addrtype
The type of address; always AF_INET or AF_INET6 at present.
h_length
The length of the address in bytes.
h_addr_list
An array of pointers to network addresses for the host (in network
byte order), terminated by a NULL pointer.
h_addr The first address in h_addr_list for backward compatibility.
//struct hostent *gethostbyname(const char *name);
*/
#include <stdio.h>
<