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

302 lines
8.5 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_send()--Send Buffered Domain Query</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_send()--Send Buffered Domain Query or Update</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_send(char *<em>query_buffer</em>,
int <em>query_buffer_length</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_send()</em> function is used to send a query or update message
to a name server and retrieve a response.</p>
<h3>Parameters</h3>
<dl>
<dt><strong>query_buffer</strong></dt>
<dd>(Input) The pointer to the query or update message.<br>
<br>
</dd>
<dt><strong>query_buffer_length</strong></dt>
<dd>(Input) The length of <em>query_buffer</em>.<br>
<br>
</dd>
<dt><strong>answer_buffer</strong></dt>
<dd>(Output) The pointer to where the response is stored.<br>
<br>
</dd>
<dt><strong>answer_buffer_length</strong></dt>
<dd>(Input) The size of the answer_buffer.</dd>
</dl>
<br>
<h3>Authorities:</h3>
<p>No authorization is required.</p>
<br>
<h3>Return Value</h3>
<p><em>res_send()</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>
<br>
<h3>Error Conditions</h3>
<p>When the <em>res_send()</em> function fails, <em>res_send()</em> can set
<em>errno</em> to one of the following:</p>
<dl>
<dt><em>[ECONNREFUSED]</em></dt>
<dd><p>Not able to connect to a server.</p></dd>
<dt><em>[ECONVERT]</em></dt>
<dd><p>Either the input packet could not be translated
to ASCII or the answer received could not be translated to the coded character
set identifier (CCSID) currently in effect for the job.</p></dd>
<dt><em>[EINVAL]</em></dt>
<dd><p>One of the following reasons:</p>
<p>An invalid length or NULL pointer was passed to <em>res_send()</em> or
The <strong>_res</strong> could not be initialized properly or
The <strong>_res</strong> appears to be initialized but the reserved field
is not set to zeros.</p>
<p><strong>Note:</strong> No attempt is made to initialize the
<strong>_res</strong> structure if it was initialized previous to the
<em>res_send()</em> being issued.</p></dd>
<dt><em>[ESRCH]</em></dt>
<dd><p>No DNS servers were specified in
<em>nsaddr</em>.</p></dd>
<dt><em>[ETIMEDOUT]</em></dt>
<dd><p>A timeout received from a connected server.</p></dd>
<dd><p>When the <em>res_send()</em> function fails, <em>h_errno</em> (defined in
<strong>&lt;netdb.h&gt;</strong>) can also be set to one of the following:</p>
<dl>
<dt><em>HOST_NOT_FOUND</em></dt>
<dd><p>Either the input packet could not be translated
to ASCII or the answer received could not be translated to the coded character
set identifier (CCSID) currently in effect for the job.</p></dd>
<dt><em>NO_RECOVERY</em></dt>
<dd><p>An invalid length or NULL pointer was passed to
<em>res_send()</em> or the <strong>_res</strong> could not be initialized
properly.</p></dd>
</dl></dd></dl>
<p><strong>Notes:</strong>
<ul>
<li>No attempt is made to initialize the
<strong>_res</strong> structure if it was initialized previous to the
<em>res_send()</em> being issued.<br><br></li>
<li>There are numerous other values that <em>errno</em>
can be set to by the sockets functions that <em>res_send()</em> calls. The
above values are the only values that <em>res_send()</em> can specifically set.
Refer to other sockets functions for the other values. <em>errno</em> is always
set in an error condition, but <em>h_errno</em> is not necessarily set.</li>
</ul>
<p>After receiving an error reply packet, <em>res_send()</em> will set the
<em>extended_error</em> field in the <em>state</em> structure to the last reply
return code from the DNS server. See &lt;arpa/nameser.h&gt; for all possible
values of <em>ns_rcode</em>.</p>
<br>
<h3>Usage Notes</h3>
<ol>
<li><em>res_send()</em> sends the query or update to the local name server and
handles all timeouts and retries. The response packet is stored in
<em>answer_buffer</em>.<br>
<br>
</li>
<li><em>res_send()</em> calls <em>res_init()</em> if the <strong>_res</strong>
structure has not been initialized.<br>
<br>
</li>
<li><em>res_send()</em> uses the UDP protocol, except for the following cases
in which it uses TCP to send the packet.
<ul>
<li>If the RES_USEVC or RES_STAYOPEN bits are set in the options field of the
<strong>_res</strong> structure.<br>
<br>
</li>
<li>If the configuration from Change TCP/IP Domain (CHGTCPDMN) specifies that
the server protocol is TCP.<br>
<br>
</li>
<li>If the truncation bit is set in the packet header on the response from a
UDP packet, and RES_IGNTC is not set in the <strong>_res</strong>
structure.</li>
</ul>
<br>
</li>
<li><em>res_send()</em> does not perform interactive queries and expects the
name server to handle recursion.<br>
<br>
</li>
<li><em>res_send()</em> assumes that the data passed to it is EBCDIC and is in
the default coded character set identifier (CCSID) currently in effect for the
job. It translates the data from the default CCSID currently in effect for the
job to ASCII (CCSID 819) before the data is sent out to a name server. The
response that it receives from the name server is returned in the default CCSID
currently in effect for the job.<br>
<br>
</li>
<li>Unless RES_NOCACHE was specified, <em>res_send()</em> checks the cached
data for the answer to the query (but not for updates). If the answer is found
and the time to live has not expired, it is returned to the calling program in
<em>answer_buffer</em> and no attempt is made to send it on the network. If the
time to live has expired, the entry is deleted from the cache, and the query is
sent on the network. If the answer is not found in the cache,
<em>res_send()</em> also sends the query on the network. When an answer is
received from the network, it is placed in cache if it is an authoritative
answer and is not the result of an inverse query. RES_NOCACHE does not stop
answers from being cached. Authoritative negative replies, indicating the data
does not exist, will also be cached.<br>
<br>
</li>
<li>In a thread-enabled environment, the <strong>_res</strong> structure is
shared among all threads within a process.</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="resnsend.htm">res_nsend()</a>--Send Buffered Domain Query<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="ressch.htm">res_search()</a>--Search for Domain Name<br>
<br>
</li>
<li><a href="resclo.htm">res_close()</a>--Close Socket and Reset _res
Structure<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>