GETHOSTBYNAME - Linux手册页
时间:2019-08-20 18:01:16 来源:igfitidea点击:
Linux程序员手册 第3部分
更新日期: 2020-06-09
名称
gethostbyname,gethostbyaddr,sethostent,gethostent,endhostent,h_errno,herror,hstrerror,gethostbyaddr_r,gethostbyname2,gethostbyname2_r,gethostbyname_r,gethostent_r-获取网络主机条目
语法
#include <netdb.h> extern int h_errno; struct hostent *gethostbyname(const char *name); #include <sys/socket.h> /* for AF_INET */ struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type); void sethostent(int stayopen); void endhostent(void); void herror(const char *s); const char *hstrerror(int err); /* System V/POSIX extension */ struct hostent *gethostent(void); /* GNU extensions */ struct hostent *gethostbyname2(const char *name, int af); int gethostent_r( struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop); int gethostbyaddr_r(const void *addr, socklen_t len, int type, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop); int gethostbyname_r(const char *name, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop); int gethostbyname2_r(const char *name, int af, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop);
glibc的功能测试宏要求(请参阅feature_test_macros(7)):
gethostbyname2(),gethostent_r(),gethostbyaddr_r(),gethostbyname_r(),gethostbyname2_r():
- Since glibc 2.19:
- _DEFAULT_SOURCE
- Glibc versions up to and including 2.19:
- _BSD_SOURCE || _SVID_SOURCE
herror(),hstrerror():
- Since glibc 2.19:
- _DEFAULT_SOURCE
- Glibc 2.8 to 2.19:
- _BSD_SOURCE || _SVID_SOURCE
- Before glibc 2.8:
- 没有
h_errno:
- Since glibc 2.19
- _DEFAULT_SOURCE || _POSIX_C_SOURCE