Files
2026-08-07 17:38:18 +09:00

49 lines
6.8 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>ne_addr_resolve</title><link rel="stylesheet" href="../manual.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.68.1"><link rel="start" href="index.html" title="neon HTTP/WebDAV client library"><link rel="up" href="ref.html" title="neon API reference"><link rel="prev" href="refconfig.html" title="neon-config"><link rel="next" href="refbuf.html" title="ne_buffer"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">ne_addr_resolve</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="refconfig.html">Prev</a> </td><th width="60%" align="center">neon API reference</th><td width="20%" align="right"> <a accesskey="n" href="refbuf.html">Next</a></td></tr></table><hr></div><div class="refentry" lang="en"><a name="refresolve"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ne_addr_resolve, ne_addr_result, ne_addr_first, ne_addr_next, ne_addr_error, ne_addr_destroy — functions to resolve hostnames to addresses</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;ne_socket.h&gt;</pre><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="funcprototype"><code><code xmlns="" class="funcdef">ne_sock_addr *<b class="fsfunc">ne_addr_resolve</b>(</code>const char *<var xmlns="" class="pdparam">hostname</var>, int <var xmlns="" class="pdparam">flags</var><code xmlns="">)</code>;</code></div><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="funcprototype"><code><code xmlns="" class="funcdef">int <b class="fsfunc">ne_addr_result</b>(</code>const ne_sock_addr *<var xmlns="" class="pdparam">addr</var><code xmlns="">)</code>;</code></div><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="funcprototype"><code><code xmlns="" class="funcdef">const ne_inet_addr *<b class="fsfunc">ne_addr_first</b>(</code>ne_sock_addr *<var xmlns="" class="pdparam">addr</var><code xmlns="">)</code>;</code></div><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="funcprototype"><code><code xmlns="" class="funcdef">const ne_inet_addr *<b class="fsfunc">ne_addr_next</b>(</code>ne_sock_addr *<var xmlns="" class="pdparam">addr</var><code xmlns="">)</code>;</code></div><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="funcprototype"><code><code xmlns="" class="funcdef">char *<b class="fsfunc">ne_addr_error</b>(</code>const ne_sock_addr *<var xmlns="" class="pdparam">addr</var>, char *<var xmlns="" class="pdparam">buffer</var>, size_t <var xmlns="" class="pdparam">bufsiz</var><code xmlns="">)</code>;</code></div><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="funcprototype"><code><code xmlns="" class="funcdef">void <b class="fsfunc">ne_addr_destroy</b>(</code>ne_sock_addr *<var xmlns="" class="pdparam">addr</var><code xmlns="">)</code>;</code></div></div></div><div class="refsect1" lang="en"><a name="id2930350"></a><h2>Description</h2><p>The <code class="function">ne_addr_resolve</code> function resolves
the given <code class="parameter">hostname</code>, returning an
<em class="type">ne_sock_addr</em> object representing the address (or
addresses) associated with the hostname. The
<code class="parameter">flags</code> parameter is currently unused, and
must be passed as 0.</p><p>The <code class="parameter">hostname</code> passed to
<code class="function">ne_addr_resolve</code> can be a DNS hostname
(e.g. <code class="literal">"www.example.com"</code>) or an IPv4 dotted quad
(e.g. <code class="literal">"192.0.34.72"</code>); or, on systems which
support IPv6, an IPv6 hex address, which may be enclosed in
brackets, e.g. <code class="literal">"[::1]"</code>.</p><p>To determine whether the hostname was successfully resolved,
the <code class="function">ne_addr_result</code> function is used, which
returns non-zero if an error occurred. If an error did occur, the
<code class="function">ne_addr_error</code> function can be used, which
will copy the error string into a given
<code class="parameter">buffer</code> (of size
<code class="parameter">bufsiz</code>).</p><p>The functions <code class="function">ne_addr_first</code> and
<code class="function">ne_addr_next</code> are used to retrieve the
Internet addresses associated with an address object which has
been successfully resolved. <code class="function">ne_addr_first</code>
returns the first address; <code class="function">ne_addr_next</code>
returns the next address after the most recent call to
<code class="function">ne_addr_next</code> or
<code class="function">ne_addr_first</code>, or <code class="literal">NULL</code> if there are no more
addresses. The <em class="type">ne_inet_addr</em> pointer returned by
these functions can be passed to
<code class="function">ne_sock_connect</code> to connect a socket.</p><p>After the address object has been used, it should be
destroyed using <code class="function">ne_addr_destroy</code>.</p></div><div class="refsect1" lang="en"><a name="id2930524"></a><h2>Return value</h2><p><code class="function">ne_addr_resolve</code> returns a pointer to an
address object, and never <code class="literal">NULL</code>.
<code class="function">ne_addr_error</code> returns the
<code class="parameter">buffer</code> parameter .</p></div><div class="refsect1" lang="en"><a name="id2930558"></a><h2>Examples</h2><p>The code below prints out the set of addresses associated
with the hostname <code class="literal">www.google.com</code>.</p><pre class="programlisting">ne_sock_addr *addr;
char buf[256];
addr = ne_addr_resolve("www.google.com", 0);
if (ne_addr_result(addr)) {
printf("Could not resolve www.google.com: %s\n",
ne_addr_error(addr, buf, sizeof buf));
} else {
const ne_inet_addr *ia;
printf("www.google.com:");
for (ia = ne_addr_first(addr); ia != NULL; ia = ne_addr_next(addr)) {
printf(" %s", ne_iaddr_print(ia, buf, sizeof buf));
}
putchar('\n');
}
ne_addr_destroy(addr);
</pre></div><div class="refsect1" lang="en"><a name="id2930589"></a><h2>See also</h2><p><a href="refiaddr.html#ne_iaddr_print">ne_iaddr_print</a></p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="refconfig.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ref.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="refbuf.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">neon-config </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> ne_buffer</td></tr></table></div></body></html>