⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lwres_gethostent.3

📁 bind 9.3结合mysql数据库
💻 3
字号:
.\" Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC").\" Copyright (C) 2001  Internet Software Consortium..\".\" Permission to use, copy, modify, and distribute this software for any.\" purpose with or without fee is hereby granted, provided that the above.\" copyright notice and this permission notice appear in all copies..\".\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH.\" REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY.\" AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,.\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM.\" LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE.\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR.\" PERFORMANCE OF THIS SOFTWARE..\".\" $Id: lwres_gethostent.3,v 1.16.2.1.8.1 2004/03/06 07:41:43 marka Exp $.\".TH "LWRES_GETHOSTENT" "3" "Jun 30, 2000" "BIND9" "".SH NAMElwres_gethostbyname, lwres_gethostbyname2, lwres_gethostbyaddr, lwres_gethostent, lwres_sethostent, lwres_endhostent, lwres_gethostbyname_r, lwres_gethostbyaddr_r, lwres_gethostent_r, lwres_sethostent_r, lwres_endhostent_r \- lightweight resolver get network host entry.SH SYNOPSIS\fB#include <lwres/netdb.h>.sp.nastruct hostent *lwres_gethostbyname(const char *name);.ad.sp.nastruct hostent *lwres_gethostbyname2(const char *name, int af);.ad.sp.nastruct hostent *lwres_gethostbyaddr(const char *addr, int len, int type);.ad.sp.nastruct hostent *lwres_gethostent(void);.ad.sp.navoidlwres_sethostent(int stayopen);.ad.sp.navoidlwres_endhostent(void);.ad.sp.nastruct hostent *lwres_gethostbyname_r(const char *name, struct hostent *resbuf, char *buf, int buflen, int *error);.ad.sp.nastruct hostent *lwres_gethostbyaddr_r(const char *addr, int len, int type, struct hostent *resbuf, char *buf, int buflen, int *error);.ad.sp.nastruct hostent *lwres_gethostent_r(struct hostent *resbuf, char *buf, int buflen, int *error);.ad.sp.navoidlwres_sethostent_r(int stayopen);.ad.sp.navoidlwres_endhostent_r(void);.ad\fR.SH "DESCRIPTION".PPThese functions provide hostname-to-address andaddress-to-hostname lookups by means of the lightweight resolver.They are similar to the standard\fBgethostent\fR(3)functions provided by most operating systems.They use a\fBstruct hostent\fRwhich is usually defined in\fI<namedb.h>\fR..sp.nfstruct  hostent {        char    *h_name;        /* official name of host */        char    **h_aliases;    /* alias list */        int     h_addrtype;     /* host address type */        int     h_length;       /* length of address */        char    **h_addr_list;  /* list of addresses from name server */};#define h_addr  h_addr_list[0]  /* address, for backward compatibility */.sp.fi.PPThe members of this structure are:.TP\fBh_name\fRThe official (canonical) name of the host..TP\fBh_aliases\fRA NULL-terminated array of alternate names (nicknames) for the host..TP\fBh_addrtype\fRThe type of address being returned \(em\fBPF_INET\fRor\fBPF_INET6\fR..TP\fBh_length\fRThe length of the address in bytes..TP\fBh_addr_list\fRA \fBNULL\fRterminated array of network addresses for the host.Host addresses are returned in network byte order..PPFor backward compatibility with very old software,h_addris the first address inh_addr_list..PP\fBlwres_gethostent()\fR,\fBlwres_sethostent()\fR,\fBlwres_endhostent()\fR,\fBlwres_gethostent_r()\fR,\fBlwres_sethostent_r()\fRand\fBlwres_endhostent_r()\fRprovide iteration over the known host entries on systems thatprovide such functionality through facilities like\fI/etc/hosts\fRor NIS. The lightweight resolver does not currently implementthese functions; it only provides them as stub functions that alwaysreturn failure..PP\fBlwres_gethostbyname()\fR and\fBlwres_gethostbyname2()\fR look up the hostname\fIname\fR.\fBlwres_gethostbyname()\fR always looks for an IPv4address while \fBlwres_gethostbyname2()\fR looks for anaddress of protocol family \fIaf\fR: either\fBPF_INET\fR or \fBPF_INET6\fR \(em IPv4 or IPV6addresses respectively. Successful calls of the functions return a\fBstruct hostent\fRfor the name that was looked up.\fBNULL\fR is returned if the lookups by\fBlwres_gethostbyname()\fR or\fBlwres_gethostbyname2()\fR fail..PPReverse lookups of addresses are performed by\fBlwres_gethostbyaddr()\fR.\fIaddr\fR is an address of length\fIlen\fR bytes and protocol family\fItype\fR \(em \fBPF_INET\fR or\fBPF_INET6\fR.\fBlwres_gethostbyname_r()\fR is a thread-safe functionfor forward lookups. If an error occurs, an error code is returned in\fI*error\fR.\fIresbuf\fR is a pointer to a \fBstructhostent\fR which is initialised by a successful call to\fBlwres_gethostbyname_r()\fR .\fIbuf\fR is a buffer of length\fIlen\fR bytes which is used to store theh_name, h_aliases, andh_addr_list elements of the \fBstructhostent\fR returned in \fIresbuf\fR.Successful calls to \fBlwres_gethostbyname_r()\fRreturn \fIresbuf\fR,which is a pointer to the \fBstruct hostent\fR it created..PP\fBlwres_gethostbyaddr_r()\fR is a thread-safe functionthat performs a reverse lookup of address \fIaddr\fRwhich is \fIlen\fR bytes long and is of protocolfamily \fItype\fR \(em \fBPF_INET\fR or\fBPF_INET6\fR. If an error occurs, the error code is returnedin \fI*error\fR. The other function parameters areidentical to those in \fBlwres_gethostbyname_r()\fR.\fIresbuf\fR is a pointer to a \fBstructhostent\fR which is initialised by a successful call to\fBlwres_gethostbyaddr_r()\fR.\fIbuf\fR is a buffer of length\fIlen\fR bytes which is used to store theh_name, h_aliases, andh_addr_list elements of the \fBstructhostent\fR returned in \fIresbuf\fR. Successfulcalls to \fBlwres_gethostbyaddr_r()\fR return\fIresbuf\fR, which is a pointer to the\fBstruct hostent()\fR it created..SH "RETURN VALUES".PPThe functions\fBlwres_gethostbyname()\fR,\fBlwres_gethostbyname2()\fR,\fBlwres_gethostbyaddr()\fR,and\fBlwres_gethostent()\fRreturn NULL to indicate an error. In this case the global variable\fBlwres_h_errno\fRwill contain one of the following error codes defined in\fI<lwres/netdb.h>\fR:.TP\fBHOST_NOT_FOUND\fRThe host or address was not found..TP\fBTRY_AGAIN\fRA recoverable error occurred, e.g., a timeout.Retrying the lookup may succeed..TP\fBNO_RECOVERY\fRA non-recoverable error occurred..TP\fBNO_DATA\fRThe name exists, but has no address informationassociated with it (or vice versa in the caseof a reverse lookup). The code NO_ADDRESSis accepted as a synonym for NO_DATA for backwardscompatibility..PP\fBlwres_hstrerror\fR(3)translates these error codes to suitable error messages..PP\fBlwres_gethostent()\fRand\fBlwres_gethostent_r()\fRalways return\fBNULL\fR..PPSuccessful calls to \fBlwres_gethostbyname_r()\fR and\fBlwres_gethostbyaddr_r()\fR return\fIresbuf\fR, a pointer to the \fBstructhostent\fR that was initialised by these functions. They return\fBNULL\fR if the lookups fail or if \fIbuf\fRwas too small to hold the list of addresses and names referenced bythe h_name, h_aliases, andh_addr_list elements of the \fBstructhostent\fR. If \fIbuf\fR was too small, both\fBlwres_gethostbyname_r()\fR and\fBlwres_gethostbyaddr_r()\fR set the global variable\fBerrno\fR to ERANGE..SH "SEE ALSO".PP\fBgethostent\fR(3),\fBlwres_getipnode\fR(3),\fBlwres_hstrerror\fR(3).SH "BUGS".PP\fBlwres_gethostbyname()\fR,\fBlwres_gethostbyname2()\fR,\fBlwres_gethostbyaddr()\fRand\fBlwres_endhostent()\fRare not thread safe; they return pointers to static data and provide error codes through a global variable.Thread-safe versions for name and address lookup are provided by\fBlwres_gethostbyname_r()\fR,and\fBlwres_gethostbyaddr_r()\fRrespectively..PPThe resolver daemon does not currently support any non-DNSname services such as \fI/etc/hosts\fRor\fBNIS\fR,consequently the above functions don't, either.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -