ibm-information-center/dist/eclipse/plugins/i5OS.ic.apis_5.4.0.1/ressch.htm

255 lines
6.7 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
<title>res_search()--Search for Domain Name</title>
<!-- Begin Header Records ========================================== -->
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<!-- Unix8 SCRIPT J converted by B2H R4.1 (346) (CMS) by V2KEA304 -->
<!-- at RCHVMW2 on 17 Feb 1999 at 11:05:09 -->
<!-- Edited by Kersten Feb 02 -->
<!--End Header Records -->
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</head>
<body>
<a name="Top_Of_Page"></a>
<!-- Java sync-link -->
<script type="text/javascript" language="Javascript" src="../rzahg/synch.js">
</script>
<h2>res_search()--Search for Domain Name</h2>
<div class="box" style="width: 60%;">
<br>
&nbsp;&nbsp;Syntax<br>
<pre>
#include &lt;sys/types.h&gt;
#include &lt;netinet/in.h&gt;
#include &lt;arpa/nameser.h&gt;
#include &lt;resolv.h&gt;
int res_search(char *<em>domain_name</em>,
int <em>class</em>,
int <em>type</em>,
char *<em>answer_buffer</em>,
int <em>answer_buffer_length</em>)
</pre>
<br>
&nbsp;&nbsp;Service Program Name: QSOSRV2<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Default Public Authority: *USE<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Threadsafe: Yes<br>
<!-- iddvc RMBR -->
<br>
</div>
<p>The <em>res_search()</em> function is used to make a query message and wait
for a response.</p>
<br>
<h3>Parameters</h3>
<dl>
<dt><strong>domain_name</strong></dt>
<dd>(Input) The pointer to the domain name.<br>
<br>
</dd>
<dt><strong>class</strong></dt>
<dd>(Input) The class of data being looked for. See <a href=
"resmkq.htm">res_mkquery()</a> or &lt;arpa/nameser.h&gt; for possible
values.<br>
<br>
</dd>
<dt><strong>type</strong></dt>
<dd>(Input) The type of request being made. See <a href=
"resmkq.htm">res_mkquery()</a> or &lt;arpa/nameser.h&gt; for possible
values.<br>
<br>
</dd>
<dt><strong>answer_buffer</strong></dt>
<dd>(Output) The pointer to an address where the response is stored.<br>
<br>
</dd>
<dt><strong>answer_buffer_length</strong></dt>
<dd>(Input) The size of the answer area.</dd>
</dl>
<br>
<h3>Return Value</h3>
<p><em>res_search()</em> returns an integer. Possible values are:</p>
<ul>
<li>-1 (unsuccessful)<br>
<br>
</li>
<li>n (successful), where n is the actual size of the answer returned.</li>
</ul>
<h3>Authorities:</h3>
<p>Authorization of *R (allow access to the object) to the host aliases file
specified by the <em>HOSTALIASES</em> environment variable.</p>
<p>You also need *X authority to each directory in the path of the host aliases
file.</p>
<br>
<h3>Error Conditions</h3>
<p>When the <em>res_search()</em> function fails, <em>errno</em> can be set to
one of the following:</p>
<dl>
<dt><em>[EACCES]</em></dt>
<dd><p>Permission denied. The process does not have the
appropriate privileges to the host aliases file specified by the
<em>HOSTALIASES</em> environment variable.</p></dd>
<dt><em>[EFAULT]</em></dt>
<dd><p>The system detected a pointer that was invalid
while attempting to access an input pointer.</p></dd>
<dt><em>[EINVAL]</em></dt>
<dd><p>The <strong>_res</strong> appears to be
initialized but the reserved field is not set to zeros.</p></dd>
<dd><p>When the <em>res_search()</em> function fails, <em>h_errno</em> (defined in
<strong>&lt;netdb.h&gt;</strong>) can be set to one of the following:</p>
<dl>
<dt><em>[HOST_NOT_FOUND]</em></dt>
<dd><p>(Set by the call to <em>res_query()</em> ) The
domain name specified by the <em>domain_name</em> parameter was not found. The
return code in the response packet was NXDOMAIN.</p></dd>
<dt><em>[TRY_AGAIN]</em></dt>
<dd><p>Either the name server is not running or the name
server returned SERVFAIL in the response packet.</p></dd>
<dt><em>[NO_RECOVERY]</em></dt>
<dd><p>(Set by the call to <em>res_query()</em> ) An
unrecoverable error has occurred. Either the domain name could not be
compressed because it was invalid or the name server returned FORMERR, NOTIMP,
or REFUSED.</p></dd>
<dt><em>[NO_DATA]</em></dt>
<dd><p>(Set by the call to <em>res_query()</em> ) The
domain name exists but there is no data of the requested type.</p></dd>
</dl></dd>
</dl>
<br>
<h3>Usage Notes</h3>
<ol>
<li>The <em>res_search()</em> function implements the default and search rules
controlled by the RES_DEFNAMES and RES_DNSRCH options. <em>res_search()</em>
takes the domain name received in <em>domain_name</em>, and makes it fully
qualified (if it is not already). <em>res_search()</em> also calls
<em>res_query()</em>, passing it the different domain names to look up, until a
successful response is received.<br>
<br>
</li>
<li><em>res_search()</em> calls <em>res_init()</em> if the
<strong>_res</strong> structure has not been initialized.<br>
<br>
</li>
<li><em>res_search()</em> expects EBCDIC data as input. The output from
<em>res_search()</em> is also EBCDIC.<br>
<br>
</li>
<li>In a thread-enabled environment, the <strong>_res</strong> structure is
shared among all threads within a process.<br>
<br>
</li>
<li><em>res_search()</em> will resolve local host aliases to a domain name
which are then resolved with a query using DNS. See <a href=
"reshostalias.htm">res_hostalias()</a> for more information on aliases.<br>
<br>
</li>
</ol>
<br>
<h3>Related Information</h3>
<ul>
<li><a href="hstrerror.htm">hstrerror()</a>--Retrieve Resolver Error
Message<br>
<br>
</li>
<li><a href="resnsearch.htm">res_nsearch()</a>--Search for Domain Name<br>
<br>
</li>
<li><a href="reshostalias.htm">res_hostalias()</a>--Retrieve the host alias<br>
<br>
</li>
<li><a href="resini.htm">res_init()</a>--Initialize _res Structure<br>
<br>
</li>
<li><a href="resmkq.htm">res_mkquery()</a>--Place Domain Query in Buffer<br>
<br>
</li>
<li><a href="resqry.htm">res_query()</a>--Send Domain Query<br>
<br>
</li>
<li><a href="resclo.htm">res_close()--</a>Close Socket and Reset _res
Structure<br>
<br>
</li>
<li><a href="ressnd.htm">res_send()</a>--Send Buffered Domain Query<br>
<br>
</li>
<li><a href="resxlt.htm">res_xlate()</a>--Translate DNS Packets</li>
</ul>
<br>
<hr>
API introduced: V3R1
<hr>
<center>
<table cellpadding="2" cellspacing="2">
<tr align="center">
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
"unix.htm">UNIX-Type APIs</a> | <a href="aplist.htm">APIs by category</a> </td>
</tr>
</table>
</center>
</body>
</html>