*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->Linux man pages -> getipnodebyname (3)              
Title
Content
Arch
Section
 

getipnodebyname(3)

Contents


NAME    [Toc]    [Back]

       getipnodebyname,  getipnodebyaddr, freehostent - get network host names
       and addresses

SYNOPSIS    [Toc]    [Back]

       #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);

DESCRIPTION    [Toc]    [Back]

       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    [Toc]    [Back]
	      The name parameter points to a dotted-quad  IPv4	address  or  a
	      name of an IPv4 network host.

       AF_INET6    [Toc]    [Back]
	      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    [Toc]    [Back]
	      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    [Toc]    [Back]
	      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    [Toc]    [Back]
	      The  addr  parameter  points to a struct in_addr and len must be
	      set to sizeof(struct in_addr).

       AF_INET6    [Toc]    [Back]
	      The addr parameter points to a struct in6_addr and len  must  be
	      set to sizeof(struct in6_addr).

RETURN VALUE    [Toc]    [Back]

       A  null	pointer  is  returned if an error occurred, and error_num will
       contain an error code from the following list:

       HOST_NOT_FOUND    [Toc]    [Back]
	      The host name or network address was not found.

       NO_ADDRESS    [Toc]    [Back]
	      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    [Toc]    [Back]
	      The domain name server returned a permanent failure response.

       TRY_AGAIN    [Toc]    [Back]
	      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    [Toc]    [Back]

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



Linux Man Page			  2000-12-18		    getipnodebyname(3)
[ Back ]
 Similar pages
Name OS Title
krb.realms Tru64 Contains configuration information that associates host names with realm names
addr2line NetBSD convert addresses into file names and line numbers
addr2line FreeBSD convert addresses into file names and line numbers.
addr2line Linux convert addresses into file names and line numbers.
nameif Linux name network interfaces based on MAC addresses
host FreeBSD look up host names using domain server
hosts Linux The static table lookup for host names
users Linux print the user names of users currently logged in to the current host
bthost FreeBSD look up Bluetooth host names and Protocol Service Multiplexor values
gethostent FreeBSD get network host entry
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service