Мне нужно по С + + а не о FreeBSD i PHP!!
Можно поинтересоваться связью между FreeBSD и PHP? Это так, для обшего моего развития.
А вообше мой справочник говорит:
struct hostent Data Type
This data type is used to represent an entry in the hosts database. It has the following members:
char *h_name
This is the "official" name of the host.
char **h_aliases
These are alternative names for the host, represented as a null-terminated vector of strings.
int h_addrtype
This is the host address type; in practice, its value is always either AF_INET or AF_INET6, with the latter being used for IPv6 hosts. In principle other kinds of addresses could be represented in the database as well as Internet addresses; if this were done, you might find a value in this field other than AF_INET or AF_INET6. See Socket Addresses.
int h_length
This is the length, in bytes, of each address.
char **h_addr_list
This is the vector of addresses for the host. (Recall that the host might be connected to multiple networks and have different addresses on each one.) The vector is terminated by a null pointer.
char *h_addr
This is a synonym for h_addr_list[0]; in other words, it is the first host address.
As far as the host database is concerned, each address is just a block of memory h_length bytes long. But in other contexts there is an implicit assumption that you can convert IPv4 addresses to a struct in_addr or an uint32_t. Host addresses in a struct hostent structure are always given in network byte order; see Byte Order.
You can use gethostbyname, gethostbyname2 or gethostbyaddr to search the hosts database for information about a particular host. The information is returned in a statically-allocated structure; you must copy the information if you need to save it across calls. You can also use getaddrinfo and getnameinfo to obtain this information.
struct hostent * gethostbyname (const char *name) Function
The gethostbyname function returns information about the host named name. If the lookup fails, it returns a null pointer.
В обших словах, эта функция берет имя сервера. Делает запрос на DNS сервер и получает IP адреса и официальные наименования. Хорошо илюстрирует работу данной функции команда nslookup в консоле.