getipnodebyname(3) | Library Functions Manual | getipnodebyname(3) |
getipnodebyname, getipnodebyaddr, freehostent - get network hostnames and addresses
Standard C library (libc, -lc)
#include <sys/types.h> #include <sys/socket.h> #include <netdb.h>
[[deprecated]] struct hostent *getipnodebyname(const char *name, int af, int flags, int *error_num); [[deprecated]] struct hostent *getipnodebyaddr(const void addr[.len], size_t len, int af, int *error_num); [[deprecated]] void freehostent(struct hostent *ip);
These functions are deprecated (and unavailable in glibc). Use getaddrinfo(3) and getnameinfo(3) instead.
The getipnodebyname() and getipnodebyaddr() functions return the names and addresses of a network host. These functions return a pointer to the following structure:
struct hostent { char *h_name; char **h_aliases; int h_addrtype; int h_length; char **h_addr_list; };
These functions replace the gethostbyname(3) and gethostbyaddr(3) functions, which could access only the IPv4 network address family. The getipnodebyname() and getipnodebyaddr() functions can access multiple network address families.
Unlike the gethostby functions, these functions return pointers to dynamically allocated memory. The freehostent() function is used to release the dynamically allocated memory after the caller no longer needs the hostent structure.
The getipnodebyname() function looks up network addresses for the host specified by the name argument. The af argument specifies one of the following values:
The flags argument specifies additional options. More than one option can be specified by bitwise OR-ing them together. flags should be set to 0 if no options are desired.
The getipnodebyaddr() function looks up the name of the host whose network address is specified by the addr argument. The af argument specifies one of the following values:
NULL is returned if an error occurred, and error_num will contain an error code from the following list:
A successful query returns a pointer to a hostent structure that contains the following fields:
None.
RFC 2553.
Present in glibc 2.1.91-95, but removed again. Several UNIX-like systems support them, but all call them deprecated.
getaddrinfo(3), getnameinfo(3), inet_ntop(3), inet_pton(3)
2023-10-31 | Linux man-pages 6.7 |