1<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>ne_addr_resolve</title><link rel="stylesheet" type="text/css" href="../manual.css"><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" 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" title="ne_addr_resolve"><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" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include <ne_socket.h></pre><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">ne_sock_addr *<b class="fsfunc">ne_addr_resolve</b>(</code></td><td>const char *<var class="pdparam">hostname</var>, </td></tr><tr><td>��</td><td>int <var class="pdparam">flags</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer">��</div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">ne_addr_result</b>(</code></td><td>const ne_sock_addr *<var class="pdparam">addr</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer">��</div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">const ne_inet_addr *<b class="fsfunc">ne_addr_first</b>(</code></td><td>ne_sock_addr *<var class="pdparam">addr</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer">��</div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">const ne_inet_addr *<b class="fsfunc">ne_addr_next</b>(</code></td><td>ne_sock_addr *<var class="pdparam">addr</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer">��</div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">char *<b class="fsfunc">ne_addr_error</b>(</code></td><td>const ne_sock_addr *<var class="pdparam">addr</var>, </td></tr><tr><td>��</td><td>char *<var class="pdparam">buffer</var>, </td></tr><tr><td>��</td><td>size_t <var class="pdparam">bufsiz</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer">��</div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">void <b class="fsfunc">ne_addr_destroy</b>(</code></td><td>ne_sock_addr *<var class="pdparam">addr</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer">��</div></div></div><div class="refsect1" title="Description"><a name="id448486"></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" title="Return value"><a name="id448631"></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" title="Examples"><a name="id448661"></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; 33char buf[256]; 34 35addr = ne_addr_resolve("www.google.com", 0); 36if (ne_addr_result(addr)) { 37 printf("Could not resolve www.google.com: %s\n", 38 ne_addr_error(addr, buf, sizeof buf)); 39} else { 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)); 44 } 45 putchar('\n'); 46} 47ne_addr_destroy(addr); 48</pre></div><div class="refsect1" title="See also"><a name="id448685"></a><h2>See also</h2><p><a class="xref" 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> 49