Movatterモバイル変換


[0]ホーム

URL:


man7.org > Linux >man-pages

Linux/UNIX system programming training


getipnodebyname(3) — Linux manual page

NAME |LIBRARY |SYNOPSIS |DESCRIPTION |RETURN VALUE |STANDARDS |HISTORY |SEE ALSO |COLOPHON

getipnodebyname(3)       Library Functions Manualgetipnodebyname(3)

NAME        top

       getipnodebyname, getipnodebyaddr, freehostent - get network       hostnames and addresses

LIBRARY        top

       Standard C library (libc,-lc)

SYNOPSIS        top

#include <sys/types.h>#include <sys/socket.h>#include <netdb.h>[[deprecated]] struct hostent *getipnodebyname(const char *name, intaf,intflags, int *error_num);[[deprecated]] struct hostent *getipnodebyaddr(size_t size;const voidaddr[size],size_tsize, intaf,int *error_num);[[deprecated]] void freehostent(struct hostent *ip);

DESCRIPTION        top

       These functions are deprecated (and unavailable in glibc).  Usegetaddrinfo(3) andgetnameinfo(3) instead.       Thegetipnodebyname() andgetipnodebyaddr() 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 thegethostbyname(3) andgethostbyaddr(3)       functions, which could access only the IPv4 network address       family.  Thegetipnodebyname() andgetipnodebyaddr() functions can       access multiple network address families.       Unlike thegethostbyfunctions, these functions return pointers to       dynamically allocated memory.  Thefreehostent() function is used       to release the dynamically allocated memory after the caller no       longer needs thehostent structure.getipnodebyname() arguments       Thegetipnodebyname() function looks up network addresses for the       host specified by thename argument.  Theaf argument specifies       one of the following values:AF_INET              Thename argument points to a dotted-quad IPv4 address or a              name of an IPv4 network host.AF_INET6              Thename argument points to a hexadecimal IPv6 address or a              name of an IPv6 network host.       Theflags 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.AI_V4MAPPED              This flag is used withAF_INET6to request a query for IPv4              addresses instead of IPv6 addresses; the IPv4 addresses              will be mapped to IPv6 addresses.AI_ALLThis flag is used withAI_V4MAPPEDto 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 withAF_INET6to 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 theAI_V4MAPPEDflag.AI_DEFAULT              This flag is equivalent to(AI_ADDRCONFIG | AI_V4MAPPED).getipnodebyaddr() arguments       Thegetipnodebyaddr() function looks up the name of the host whose       network address is specified by theaddr argument.  Theaf       argument specifies one of the following values:AF_INET              Theaddr argument points to astruct in_addr andsize must              be set tosizeof(struct in_addr).AF_INET6              Theaddr argument points to astruct in6_addr andsize must              be set tosizeof(struct in6_addr).

RETURN VALUE        top

       NULL is returned if an error occurred, anderror_num will contain       an error code from the following list:HOST_NOT_FOUND              The hostname 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 ahostent 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 theaf argument togetipnodebyname() orgetipnodebyaddr().h_addrtype will always beAF_INETif              theaf argument wasAF_INET.h_addrtype will always beAF_INET6if theaf argument wasAF_INET6.h_length              This field will be set tosizeof(struct in_addr) ifh_addrtype isAF_INET, and tosizeof(struct in6_addr) ifh_addrtype isAF_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.

STANDARDS        top

       None.

HISTORY        top

       RFC 2553.       Present in glibc 2.1.91-95, but removed again.  Several UNIX-like       systems support them, but all call them deprecated.

SEE ALSO        top

getaddrinfo(3),getnameinfo(3),inet_ntop(3),inet_pton(3)

COLOPHON        top

       This page is part of theman-pages (Linux kernel and C library       user-space interface documentation) project.  Information about       the project can be found at        ⟨https://www.kernel.org/doc/man-pages/⟩.  If you have a bug report       for this manual page, see       ⟨https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING⟩.       This page was obtained from the tarball man-pages-6.15.tar.gz       fetched from       ⟨https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/⟩ on       2025-08-11.  If you discover any rendering problems in this HTML       version of the page, or you believe there is a better or more up-       to-date source for the page, or you have corrections or       improvements to the information in this COLOPHON (which isnot       part of the original manual page), send a mail to       man-pages@man7.orgLinux man-pages 6.15            2025-06-28getipnodebyname(3)


HTML rendering created 2025-09-06 byMichael Kerrisk, author ofThe Linux Programming Interface.

For details of in-depthLinux/UNIX system programming training courses that I teach, lookhere.

Hosting byjambit GmbH.

Cover of TLPI


[8]ページ先頭

©2009-2025 Movatter.jp