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

📄 lwres_getaddrinfo.3

📁 bind 9.3结合mysql数据库
💻 3
字号:
.\" Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC").\" Copyright (C) 2000, 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_getaddrinfo.3,v 1.16.2.1.8.2 2004/03/06 07:41:43 marka Exp $.\".TH "LWRES_GETADDRINFO" "3" "Jun 30, 2000" "BIND9" "".SH NAMElwres_getaddrinfo, lwres_freeaddrinfo \- socket address structure to host and service name.SH SYNOPSIS\fB#include <lwres/netdb.h>.sp.naintlwres_getaddrinfo(const char *hostname, const char *servname, const struct addrinfo *hints, struct addrinfo **res);.ad.sp.navoidlwres_freeaddrinfo(struct addrinfo *ai);.ad\fR.PPIf the operating system does not provide a\fBstruct addrinfo\fR,the following structure is used:.sp.nfstruct  addrinfo {        int             ai_flags;       /* AI_PASSIVE, AI_CANONNAME */        int             ai_family;      /* PF_xxx */        int             ai_socktype;    /* SOCK_xxx */        int             ai_protocol;    /* 0 or IPPROTO_xxx for IPv4 and IPv6 */        size_t          ai_addrlen;     /* length of ai_addr */        char            *ai_canonname;  /* canonical name for hostname */        struct sockaddr *ai_addr;       /* binary address */        struct addrinfo *ai_next;       /* next structure in linked list */};.sp.fi.SH "DESCRIPTION".PP\fBlwres_getaddrinfo()\fRis used to get a list of IP addresses and port numbers for host\fIhostname\fRand service\fIservname\fR.The function is the lightweight resolver's implementation of\fBgetaddrinfo()\fRas defined in RFC2133.\fIhostname\fRand\fIservname\fRare pointers to null-terminatedstrings or\fBNULL\fR.\fIhostname\fRis either a host name or a numeric host address string: a dotted decimalIPv4 address or an IPv6 address.\fIservname\fRis either a decimal port number or a service name as listed in\fI/etc/services\fR..PP\fIhints\fRis an optional pointer to a\fBstruct addrinfo\fR.This structure can be used to provide hints concerning the type of socketthat the caller supports or wishes to use.The caller can supply the following structure elements in\fI*hints\fR:.TP\fBai_family\fRThe protocol family that should be used.Whenai_familyis set to\fBPF_UNSPEC\fR,it means the caller will accept any protocol family supported by theoperating system..TP\fBai_socktype\fRdenotes the type of socket \(em\fBSOCK_STREAM\fR,\fBSOCK_DGRAM\fRor\fBSOCK_RAW\fR\(em that is wanted.Whenai_socktypeis zero the caller will accept any socket type..TP\fBai_protocol\fRindicates which transport protocol is wanted: IPPROTO_UDP or IPPROTO_TCP.Ifai_protocolis zero the caller will accept any protocol..TP\fBai_flags\fRFlag bits.If the\fBAI_CANONNAME\fRbit is set, a successful call to\fBlwres_getaddrinfo()\fRwill return a null-terminated string containing the canonical nameof the specified hostname inai_canonnameof the first\fBaddrinfo\fRstructure returned.Setting the\fBAI_PASSIVE\fRbit indicates that the returned socket address structure is intendedfor used in a call to\fBbind\fR(2).In this case, if the hostname argument is a\fBNULL\fRpointer, then the IP address portion of the socketaddress structure will be set to\fBINADDR_ANY\fRfor an IPv4 address or\fBIN6ADDR_ANY_INIT\fRfor an IPv6 address.Whenai_flagsdoes not set the\fBAI_PASSIVE\fRbit, the returned socket address structure will be readyfor use in a call to\fBconnect\fR(2)for a connection-oriented protocol or\fBconnect\fR(2),\fBsendto\fR(2),or\fBsendmsg\fR(2)if a connectionless protocol was chosen.The IP address portion of the socket address structure will beset to the loopback address if\fIhostname\fRis a\fBNULL\fRpointer and\fBAI_PASSIVE\fRis not set inai_flags.Ifai_flagsis set to\fBAI_NUMERICHOST\fRit indicates that\fIhostname\fRshould be treated as a numeric string defining an IPv4 or IPv6 addressand no name resolution should be attempted..PPAll other elements of the \fBstruct addrinfo\fR passedvia \fIhints\fR must be zero..PPA \fIhints\fR of \fBNULL\fR is treated as ifthe caller provided a \fBstruct addrinfo\fR initialized to zerowith ai_familyset toPF_UNSPEC..PPAfter a successful call to\fBlwres_getaddrinfo()\fR,\fI*res\fRis a pointer to a linked list of one or more\fBaddrinfo\fRstructures.Each\fBstruct addrinfo\fRin this list cn be processed by followingtheai_nextpointer, until a\fBNULL\fRpointer is encountered.The three membersai_family,ai_socktype,andai_protocolin eachreturned\fBaddrinfo\fRstructure contain the corresponding arguments for a call to\fBsocket\fR(2).For each\fBaddrinfo\fRstructure in the list, theai_addrmember points to a filled-in socket address structure of lengthai_addrlen..PPAll of the information returned by\fBlwres_getaddrinfo()\fRis dynamically allocated: the addrinfo structures, and the socketaddress structures and canonical host name strings pointed to by theaddrinfostructures.Memory allocated for the dynamically allocated structures created bya successful call to\fBlwres_getaddrinfo()\fRis released by\fBlwres_freeaddrinfo()\fR.\fIai\fRis a pointer to a\fBstruct addrinfo\fRcreated by a call to\fBlwres_getaddrinfo()\fR..SH "RETURN VALUES".PP\fBlwres_getaddrinfo()\fRreturns zero on success or one of the error codes listed in\fBgai_strerror\fR(3)if an error occurs.If both\fIhostname\fRand\fIservname\fRare\fBNULL\fR\fBlwres_getaddrinfo()\fRreturnsEAI_NONAME..SH "SEE ALSO".PP\fBlwres\fR(3),\fBlwres_getaddrinfo\fR(3),\fBlwres_freeaddrinfo\fR(3),\fBlwres_gai_strerror\fR(3),\fBRFC2133\fR,\fBgetservbyname\fR(3),\fBbind\fR(2),\fBconnect\fR(2),\fBsendto\fR(2),\fBsendmsg\fR(2),\fBsocket\fR(2).

⌨️ 快捷键说明

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