Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
freehostent(3)
Edit
PageHistory
Diff
Info
LikePages
getipnodebyname !!!getipnodebyname NAME SYNOPSIS DESCRIPTION RETURN VALUE SEE ALSO ---- !!NAME getipnodebyname, getipnodebyaddr, freehostent - get network host names and addresses !!SYNOPSIS __#include __''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''__); __ !!DESCRIPTION The getipnodebyname(3) and getipnodebyaddr(3) 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 only access the IPv4 network address family. The getipnodebyname(3) and getipnodebyaddr(3) functions can access multiple network address families. Unlike the __gethostby__ functions, these functions return pointers to dynamically allocated memory. The freehostent(3) function is used to release the dynamically allocated memory after the caller no longer needs the __hostent__ structure. __getipnodebyname parameters__ The getipnodebyname(3) function looks up network addresses for the host specified by the ''name'' parameter. The ''af'' parameter specifies one of the following values: __AF_INET__ The ''name'' parameter points to a dotted-quad IPv4 address or a name of an IPv4 network host. __AF_INET6__ The ''name'' parameter points to a hexadecimal IPv6 address or a name of an IPv6 network host. The ''flags'' parameter specifies additional options. More than one option can be specified by logically OR-ing them together. ''flags'' should be set to 0 if no options are desired. __AI_V4MAPPED__ This flag is used with __AF_INET6__ to request a query for IPv4 addresses instead of IPv6 addresses; the IPv4 addresses will be mapped to IPv6 addresses. __AI_ALL__ This flag is used with __AI_V4MAPPED__ to request a query for both IPv4 and IPv6 addresses. Any IPv4 address found will be mapped to an IPv6 address. __AI_ADDRCONFIG__ This flag is used with __AF_INET6__ to further request that queries for IPv6 addresses should not be made unless the system has at least one IPv6 address assigned to a network interface, and that queries for IPv4 addresses should not be made unless the system has at least one IPv4 address assigned to a network interface. This flag may be used by itself or with the __AI_V4MAPPED__ flag. __AI_ALL__ This flag is equivalent to __(AI_ADDRCONFIG | AI_V4MAPPED)__. __getipnodebyaddr parameters__ The getipnodebyaddr(3) function looks up the name of the host whose network address is specified by the ''addr'' parameter. The ''af'' parameter specifies one of the following values: __AF_INET__ The ''addr'' parameter points to a __struct in_addr__ and ''len'' must be set to __sizeof(struct in_addr)__. __AF_INET6__ The ''addr'' parameter points to a __struct in6_addr__ and ''len'' must be set to __sizeof(struct in6_addr)__. !!RETURN VALUE A null pointer is returned if an error occurred, and ''error_num'' will contain an error code from the following list: __HOST_NOT_FOUND__ The host name or network address was not found. __NO_ADDRESS__ The domain name server recognized the network address or name, but no answer was returned. This can happen if the network host has only IPv4 addresses and a request has been made for IPv6 information only, or vice versa. __NO_RECOVERY__ The domain name server returned a permanent failure response. __TRY_AGAIN__ The domain name server returned a temporary failure response. You might have better luck next time. A successful query returns a pointer to a __hostent__ structure that contains the following fields: __h_name__ This is the official name of this network host. __h_aliases__ This is an array of pointers to unofficial aliases for the same host. The array is terminated by a null pointer. __h_addrtype__ This is a copy of the ''af'' parameter to getipnodebyname(3) or getipnodebyaddr(3). ''h_addrtype'' will always be __AF_INET__ if the ''af'' parameter was __AF_INET__. ''h_addrtype'' will always be __AF_INET6__ if the ''af'' parameter was __AF_INET6__. __h_length__ This field will be set to __sizeof(struct in_addr)__ if ''h_addrtype'' is AF_INET, and to __sizeof(struct in6_addr)__ if ''h_addrtype'' is AF_INET6. __h_addr_list__ This is an array of one or more pointers to network address structures for the network host. The array is terminated by a null pointer. !!SEE ALSO getaddrinfo(3), inet_ntop(3), inet_pton(3) ----
3 pages link to
freehostent(3)
:
Man3f
getipnodebyaddr(3)
getipnodebyname(3)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.