![]() |
![]() |
![]() |
![]() |
Get a network host entry, given a name
#include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> struct hostent * gethostbyname_r( const char * name, struct hostent * result, char * buffer, int bufflen, int * h_errnop );
socket3r.lib, socket3s.lib
The gethostbyname_r() function is a thread-safe version of gethostbyname(). This function gets the network host entry for the host specified by name.
The host entry is returned in the struct hostent pointed to by result. During the operation, buffer (and char buffer of at least buflen bytes) is used to store host database entries; buffer should be large enough to hold all of the data associated with the host entry. A 2K buffer is usually more than enough; a 256 byte buffer is safe in most cases.
The int pointed to by h_errnop is set to an herrno value if an error occurs.
A pointer to result, or NULL if an error occurs.
If an error occurs, the int pointed to by h_errnop is set to:
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | Yes |
gethostbyaddr(), gethostbyaddr_r(), gethostbyname()
/etc/hosts, /etc/resolv.conf in the TCP/IP User Guide
![]() |
![]() |
![]() |
![]() |