GETIPNODEBYNAME(3) | Linux Programmer's Manual | GETIPNODEBYNAME(3) |
getipnodebyname, getipnodebyaddr, freehostent - get network hostnames and addresses
#include <sys/types.h> #include <sys/socket.h> #include <netdb.h>
struct hostent *getipnodebyname(const char *name, int af, int flags, int *error_num);
struct hostent *getipnodebyaddr(const void *addr, size_t len, int af, int *error_num);
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:
RFC 2553.
These functions were present in glibc 2.1.91-95, but were removed again. Several UNIX-like systems support them, but all call them deprecated.
This page is part of release 5.10 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/.
2017-09-15 | Linux |