Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4.2 |
both |
#define _XOPEN_SOURCE_EXTENDED 1
#include <netdb.h>
struct hostent *gethostent(void);
#define _OE_SOCKETS
#include <netdb.h>
struct hostent *gethostent(void);
The gethostent() call reads the next line of the local host tables.
The gethostent() call returns a pointer to the next entry in the local host tables. gethostent() uses the local host tables to get aliases.
gethostent(), gethostbyaddr(), and gethostbyname() all use the same static area to return the hostent structure. This static area is only valid until the next one of these functions is called on the same thread.
Special behavior for C++: To use this function with C++, you must use the _XOPEN_SOURCE_EXTENDED 1 feature test macro.
If successful, gethostent() returns a pointer to a hostent structure. The return value points to data that is overwritten by subsequent calls returning the same data structure.
If unsuccessful, gethostent() returns a NULL pointer, indicating an error or End Of File (EOF).