struct hostent 代表什么?

What does struct hostent stands for?

指向 hostent 的指针是 gethostbyname() 返回的结构。

确切的函数签名:struct hostent* gethostbyname(const char*)

我不知道 hostent 末尾的 'ent' 部分是什么意思。

当我试图记住我不明白的时候,我很健忘,所以请帮助我。

快速search on GitHub points to basedefs/netdb.h(网络数据库操作的定义)

The <netdb.h> header shall define the hostent structure that includes at least the following members:

char   *h_name       Official name of the host. 
char  **h_aliases    A pointer to an array of pointers to 
                     alternative host names, terminated by a 
                     null pointer. 
int     h_addrtype   Address type. 
int     h_length     The length, in bytes, of the address. 
char  **h_addr_list  A pointer to an array of pointers to network 
                     addresses (in network byte order) for the host, 
                     terminated by a null pointer. 

从那里开始,official documentation for gethostbyaddr() 包括:

Entries shall be returned in hostent structures.

The gethostbyaddr() function shall return an entry containing addresses of address family type for the host with address addr.
The len argument contains the length of the address pointed to by addr.
The gethostbyaddr() function need not be reentrant. A function that is not required to be reentrant is not required to be thread-safe.

Entries shall be returned in hostent structures.

Upon successful completion, these functions shall return a pointer to a hostent structure if the requested entry was found, and a null pointer if the end of the database was reached or the requested entry was not found.

所以你有它:ent for entry。不是实体。