1
<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 <ne_socket.h></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="id2875804"></a><h2>Description</h2><p>The <code class="function">ne_addr_resolve</code> function resolves
2
the given <code class="parameter">hostname</code>, returning an
3
<em class="type">ne_sock_addr</em> object representing the address (or
4
addresses) associated with the hostname. The
5
<code class="parameter">flags</code> parameter is currently unused, and
6
must be passed as 0.</p><p>The <code class="parameter">hostname</code> passed to
7
<code class="function">ne_addr_resolve</code> can be a DNS hostname
8
(e.g. <code class="literal">"www.example.com"</code>) or an IPv4 dotted quad
9
(e.g. <code class="literal">"192.0.34.72"</code>); or, on systems which
10
support IPv6, an IPv6 hex address, which may be enclosed in
11
brackets, e.g. <code class="literal">"[::1]"</code>.</p><p>To determine whether the hostname was successfully resolved,
12
the <code class="function">ne_addr_result</code> function is used, which
13
returns non-zero if an error occurred. If an error did occur, the
14
<code class="function">ne_addr_error</code> function can be used, which
15
will copy the error string into a given
16
<code class="parameter">buffer</code> (of size
17
<code class="parameter">bufsiz</code>).</p><p>The functions <code class="function">ne_addr_first</code> and
18
<code class="function">ne_addr_next</code> are used to retrieve the
19
Internet addresses associated with an address object which has
20
been successfully resolved. <code class="function">ne_addr_first</code>
21
returns the first address; <code class="function">ne_addr_next</code>
22
returns the next address after the most recent call to
23
<code class="function">ne_addr_next</code> or
24
<code class="function">ne_addr_first</code>, or <code class="literal">NULL</code> if there are no more
25
addresses. The <em class="type">ne_inet_addr</em> pointer returned by
26
these functions can be passed to
27
<code class="function">ne_sock_connect</code> to connect a socket.</p><p>After the address object has been used, it should be
28
destroyed using <code class="function">ne_addr_destroy</code>.</p></div><div class="refsect1" lang="en"><a name="id2875978"></a><h2>Return value</h2><p><code class="function">ne_addr_resolve</code> returns a pointer to an
29
address object, and never <code class="literal">NULL</code>.
30
<code class="function">ne_addr_error</code> returns the
31
<code class="parameter">buffer</code> parameter .</p></div><div class="refsect1" lang="en"><a name="id2876013"></a><h2>Examples</h2><p>The code below prints out the set of addresses associated
32
with the hostname <code class="literal">www.google.com</code>.</p><pre class="programlisting">ne_sock_addr *addr;
35
addr = ne_addr_resolve("www.google.com", 0);
36
if (ne_addr_result(addr)) {
37
printf("Could not resolve www.google.com: %s\n",
38
ne_addr_error(addr, buf, sizeof buf));
40
const ne_inet_addr *ia;
41
printf("www.google.com:");
42
for (ia = ne_addr_first(addr); ia != NULL; ia = ne_addr_next(addr)) {
43
printf(" %s", ne_iaddr_print(ia, buf, sizeof buf));
47
ne_addr_destroy(addr);
48
</pre></div><div class="refsect1" lang="en"><a name="id2876043"></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>