📄 ares_init.3
字号:
.\".\" Copyright 1998 by the Massachusetts Institute of Technology..\".\" Permission to use, copy, modify, and distribute this.\" software and its documentation for any purpose and without.\" fee is hereby granted, provided that the above copyright.\" notice appear in all copies and that both that copyright.\" notice and this permission notice appear in supporting.\" documentation, and that the name of M.I.T. not be used in.\" advertising or publicity pertaining to distribution of the.\" software without specific, written prior permission..\" M.I.T. makes no representations about the suitability of.\" this software for any purpose. It is provided "as is".\" without express or implied warranty..\".TH ARES_INIT 3 "21 July 1998".SH NAMEares_init, ares_init_options \- Initialize a resolver channel.SH SYNOPSIS.nf.B #include <ares.h>.PP.B int ares_init(ares_channel *\fIchannel\fP).B int ares_init_options(ares_channel *\fIchannel\fP,.B struct ares_options *\fIoptions\fP, int \fIoptmask\fP).PP.B cc file.c -lares.fi.SH DESCRIPTIONThe.B ares_initfunction initializes a communications channel for name servicelookups. If it returns successfully,.B ares_initwill set the variable pointed to by.I channelto a handle used to identify the name service channel. The callershould invoke.BR ares_destroy (3)on the handle when the channel is no longer needed..PPThe.B ares_init_optionsfunction also initializes a name service channel, with additionaloptions useful for applications requiring more control over nameservice configuration. The.I optmaskparameter specifies which fields in the structure pointed to by.I optionsare set, as follows:.PP.TP 18.B ARES_OPT_FLAGS.B int \fIflags\fP;.brFlags controlling the behavior of the resolver. See below for adescription of possible flag values..TP 18.B ARES_OPT_TIMEOUT.B int \fItimeout\fP;.brThe number of seconds each name server is given to respond to a queryon the first try. (After the first try, the timeout algorithm becomesmore complicated, but scales linearly with the value of\fItimeout\fP.) The default is five seconds..TP 18.B ARES_OPT_TRIES.B int \fItries\fP;.brThe number of tries the resolver will try contacting each name serverbefore giving up. The default is four tries..TP 18.B ARES_OPT_NDOTS.B int \fIndots\fP;.brThe number of dots which must be present in a domain name for it to bequeried for "as is" prior to querying for it with the default domainextensions appended. The default value is 1 unless set otherwise byresolv.conf or the RES_OPTIONS environment variable..TP 18.B ARES_OPT_PORT.B unsigned short \fIport\fP;.brThe port to use for queries (both TCP and UDP), in network byte order.The default value is 53 (in network byte order), the standard nameservice port..TP 18.B ARES_OPT_SERVERS.B struct in_addr *\fIservers\fP;.br.B int \fInservers\fP;.brThe list of servers to contact, instead of the servers specified inresolv.conf or the local named..TP 18.B ARES_OPT_DOMAINS.B char **\fIdomains\fP;.br.B int \fIndomains\fP;.brThe domains to search, instead of the domains specified in resolv.confor the domain derived from the kernel hostname variable..TP 18.B ARES_OPT_LOOKUPS.B char *\fIlookups\fP;.brThe lookups to perform for host queries. .I lookupsshould be set to a string of the characters "b" or "f", where "b"indicates a DNS lookup and "f" indicates a lookup in the hosts file..PPThe.I flagsfield should be the bitwise or of some subset of the following values:.TP 23.B ARES_FLAG_USEVCAlways use TCP queries (the "virtual circuit") instead of UDPqueries. Normally, TCP is only used if a UDP query yields a truncatedresult..TP 23.B ARES_FLAG_PRIMARYOnly query the first server in the list of servers to query..TP 23.B ARES_FLAG_IGNTCIf a truncated response to a UDP query is received, do not fall backto TCP; simply continue on with the truncated response..TP 23.B ARES_FLAG_NORECURSEDo not set the "recursion desired" bit on outgoing queries, so thatthe name server being contacted will not try to fetch the answer fromother servers if it doesn't know the answer locally..TP 23.B ARES_FLAG_STAYOPENDo not close communciations sockets when the number of active queriesdrops to zero..TP 23.B ARES_FLAG_NOSEARCHDo not use the default search domains; only query hostnames as-is oras aliases..TP 23.B ARES_FLAG_NOALIASESDo not honor the HOSTALIASES environment variable, which normallyspecifies a file of hostname translations..TP 23.B ARES_FLAG_NOCHECKRESPDo not discard responses with the SERVFAIL, NOTIMP, or REFUSEDresponse code or responses whose questions don't match the questionsin the request. Primarily useful for writing clients which might beused to test or debug name servers..SH RETURN VALUES.I ares_initor.I ares_init_optionscan return any of the following values:.TP 14.B ARES_SUCCESSInitialization succeeded..TP 14.B ARES_EFILEA configuration file could not be read..TP 14.B ARES_ENOMEMThe process's available memory was exhausted..SH SEE ALSO.BR ares_destroy (3).SH AUTHORGreg Hudson, MIT Information Systems.brCopyright 1998 by the Massachusetts Institute of Technology.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -