.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
.\"
+.\" %%%LICENSE_START(VERBATIM)
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
.\"
.\" References consulted:
.\" Linux libc source code
.\" Modified 2002-08-05, Michael Kerrisk
.\" Modified 2004-10-31, Andries Brouwer
.\"
-.TH GETHOSTBYNAME 3 2009-12-03 "" "Linux Programmer's Manual"
+.TH GETHOSTBYNAME 3 2014-03-11 "" "Linux Programmer's Manual"
.SH NAME
gethostbyname, gethostbyaddr, sethostent, gethostent, endhostent,
h_errno,
.BR feature_test_macros (7)):
.in
.sp
+.PD 0
.ad l
.BR gethostbyname2 (),
.BR gethostent_r (),
.BR gethostbyaddr_r (),
.BR gethostbyname_r (),
.BR gethostbyname2_r ():
+.RS 4
_BSD_SOURCE || _SVID_SOURCE
+.RE
.BR herror (),
-.BR hstrerror ()
-(since glibc 2.8): _BSD_SOURCE || _SVID_SOURCE || _GNU_SOURCE
+.BR hstrerror ():
+.RS 4
+.TP 4
+Since glibc 2.8:
+_BSD_SOURCE || _SVID_SOURCE
+.TP
+Before glibc 2.8:
+none
+.RE
+
+.BR h_errno :
+.RS 4
+.TP 4
+Since glibc 2.12:
+_BSD_SOURCE || _SVID_SOURCE ||
+ (_POSIX_C_SOURCE < 200809L && _XOPEN_SOURCE < 700)
+.TP
+Before glibc 2.12:
+none
+.RE
.ad b
+.PD
.SH DESCRIPTION
The
-.BR gethostbyname* ()
+.BR gethostbyname* (),
+.BR gethostbyaddr* (),
+.BR herror (),
and
-.BR gethostbyaddr* ()
+.BR hstrerror ()
functions are obsolete.
Applications should use
-.BR getaddrinfo (3)
+.BR getaddrinfo (3),
+.BR getnameinfo (3),
and
-.BR getnameinfo (3)
+.BR gai_strerror (3)
instead.
The
The official name of the host.
.TP
.I h_aliases
-An array of alternative names for the host, terminated by a NULL pointer.
+An array of alternative names for the host, terminated by a null pointer.
.TP
.I h_addrtype
The type of address; always
.TP
.I h_addr_list
An array of pointers to network addresses for the host (in network byte
-order), terminated by a NULL pointer.
+order), terminated by a null pointer.
.TP
.I h_addr
The first address in \fIh_addr_list\fP for backward compatibility.
-.SH "RETURN VALUE"
+.SH RETURN VALUE
The
.BR gethostbyname ()
and
.BR gethostbyaddr ()
functions return the
.I hostent
-structure or a NULL pointer if an error occurs.
+structure or a null pointer if an error occurs.
On error, the
.I h_errno
variable holds an error number.
.TP
.I /etc/nsswitch.conf
name service switch configuration
-.SH "CONFORMING TO"
+.SH CONFORMING TO
POSIX.1-2001 specifies
.BR gethostbyname (),
.BR gethostbyaddr (),
The BSD prototype for
.BR gethostbyaddr ()
uses
-.I const char *
+.I "const char\ *"
for the first argument.
-.SS "System V/POSIX Extension"
+.SS System V/POSIX extension
POSIX requires the
.BR gethostent ()
call, that should return the next entry in the host data base.
On many systems a routine of this name reads
from the file
.IR /etc/hosts .
-.\" e.g., Linux, FreeBSD, Unixware, HP-UX
+.\" e.g., Linux, FreeBSD, UnixWare, HP-UX
It may be available only when the library was built without DNS support.
.\" e.g., FreeBSD, AIX
The glibc version will ignore ipv6 entries.
This function is not reentrant,
and glibc adds a reentrant version
.BR gethostent_r ().
-.SS "GNU Extensions"
+.SS GNU extensions
Glibc2 also has a
.BR gethostbyname2 ()
that works like
does not recognize components of a dotted IPv4 address string
that are expressed in hexadecimal.
.\" http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=482973
-.SH "SEE ALSO"
+.SH SEE ALSO
.BR getaddrinfo (3),
.\" .BR getipnodebyaddr (3),
.\" .BR getipnodebyname (3),
.BR hostname (7),
.BR named (8)
.\" .BR resolv+ (8)
+.SH COLOPHON
+This page is part of release 3.68 of the Linux
+.I man-pages
+project.
+A description of the project,
+information about reporting bugs,
+and the latest version of this page,
+can be found at
+\%http://www.kernel.org/doc/man\-pages/.