1gethostbyname(3)           Library Functions Manual           gethostbyname(3)
2
3
4

NAME

6       gethostbyname, gethostbyaddr, sethostent, gethostent, endhostent, h_er‐
7       rno, herror,  hstrerror,  gethostbyaddr_r,  gethostbyname2,  gethostby‐
8       name2_r, gethostbyname_r, gethostent_r - get network host entry
9

LIBRARY

11       Standard C library (libc, -lc)
12

SYNOPSIS

14       #include <netdb.h>
15
16       void sethostent(int stayopen);
17       void endhostent(void);
18
19       [[deprecated]] extern int h_errno;
20
21       [[deprecated]] struct hostent *gethostbyname(const char *name);
22       [[deprecated]] struct hostent *gethostbyaddr(const void addr[.len],
23                                                    socklen_t len, int type);
24
25       [[deprecated]] void herror(const char *s);
26       [[deprecated]] const char *hstrerror(int err);
27
28       /* System V/POSIX extension */
29       struct hostent *gethostent(void);
30
31       /* GNU extensions */
32       [[deprecated]]
33       struct hostent *gethostbyname2(const char *name, int af);
34
35       int gethostent_r(struct hostent *restrict ret,
36                        char buf[restrict .buflen], size_t buflen,
37                        struct hostent **restrict result,
38                        int *restrict h_errnop);
39
40       [[deprecated]]
41       int gethostbyaddr_r(const void addr[restrict .len], socklen_t len,
42                        int type,
43                        struct hostent *restrict ret,
44                        char buf[restrict .buflen], size_t buflen,
45                        struct hostent **restrict result,
46                        int *restrict h_errnop);
47       [[deprecated]]
48       int gethostbyname_r(const char *restrict name,
49                        struct hostent *restrict ret,
50                        char buf[restrict .buflen], size_t buflen,
51                        struct hostent **restrict result,
52                        int *restrict h_errnop);
53       [[deprecated]]
54       int gethostbyname2_r(const char *restrict name, int af,
55                        struct hostent *restrict ret,
56                        char buf[restrict .buflen], size_t buflen,
57                        struct hostent **restrict result,
58                        int *restrict h_errnop);
59
60   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
61
62       gethostbyname2(), gethostent_r(), gethostbyaddr_r(), gethostbyname_r(),
63       gethostbyname2_r():
64           Since glibc 2.19:
65               _DEFAULT_SOURCE
66           glibc up to and including 2.19:
67               _BSD_SOURCE || _SVID_SOURCE
68
69       herror(), hstrerror():
70           Since glibc 2.19:
71               _DEFAULT_SOURCE
72           glibc 2.8 to glibc 2.19:
73               _BSD_SOURCE || _SVID_SOURCE
74           Before glibc 2.8:
75               none
76
77       h_errno:
78           Since glibc 2.19
79               _DEFAULT_SOURCE || _POSIX_C_SOURCE < 200809L
80           glibc 2.12 to glibc 2.19:
81               _BSD_SOURCE || _SVID_SOURCE || _POSIX_C_SOURCE < 200809L
82           Before glibc 2.12:
83               none
84

DESCRIPTION

86       The gethostbyname*(), gethostbyaddr*(), herror(), and hstrerror() func‐
87       tions  are  obsolete.  Applications should use getaddrinfo(3), getname‐
88       info(3), and gai_strerror(3) instead.
89
90       The sethostent() function specifies, if stayopen is true  (1),  that  a
91       connected  TCP  socket  should  be used for the name server queries and
92       that the connection should remain open during successive queries.  Oth‐
93       erwise, name server queries will use UDP datagrams.
94
95       The  endhostent()  function  ends  the use of a TCP connection for name
96       server queries.
97
98       The gethostbyname() function returns a structure of  type  hostent  for
99       the given host name.  Here name is either