Files
interactive/gms/KT/sdkfreebsd64/libs/neon-0.25.4/doc/html/refiaddr.html
2026-08-07 17:38:18 +09:00

38 lines
5.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_iaddr_make</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="refgetst.html" title="ne_get_status"><link rel="next" href="refalloc.html" title="ne_malloc"></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_iaddr_make</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="refgetst.html">Prev</a> </td><th width="60%" align="center">neon API reference</th><td width="20%" align="right"> <a accesskey="n" href="refalloc.html">Next</a></td></tr></table><hr></div><div class="refentry" lang="en"><a name="refiaddr"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ne_iaddr_make, ne_iaddr_cmp, ne_iaddr_print, ne_iaddr_typeof, ne_iaddr_free — functions to manipulate and compare network addresses</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;ne_socket.h&gt;
typedef enum {
ne_iaddr_ipv4 = 0,
ne_iaddr_ipv6
} <em class="type">ne_iaddr_type</em>;</pre><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="funcprototype"><code><code xmlns="" class="funcdef">ne_inet_addr *<b class="fsfunc">ne_iaddr_make</b>(</code>ne_iaddr_type <var xmlns="" class="pdparam">type</var>, const unsigned char *<var xmlns="" class="pdparam">raw</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_iaddr_cmp</b>(</code>const ne_inet_addr *<var xmlns="" class="pdparam">ia1</var>, const ne_inet_addr *<var xmlns="" class="pdparam">ia2</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_iaddr_print</b>(</code>const ne_inet_addr *<var xmlns="" class="pdparam">ia</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">ne_iaddr_type <b class="fsfunc">ne_iaddr_typeof</b>(</code>const ne_inet_addr *<var xmlns="" class="pdparam">ia</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_iaddr_free</b>(</code>const ne_inet_addr *<var xmlns="" class="pdparam">ia</var><code xmlns="">)</code>;</code></div></div></div><div class="refsect1" lang="en"><a name="id2934071"></a><h2>Description</h2><p><code class="function">ne_iaddr_make</code> creates an
<em class="type">ne_inet_addr</em> object from a raw binary network
address; for instance the four bytes <code class="literal">0x7f 0x00 0x00
0x01</code> represent the IPv4 address
<code class="literal">127.0.0.1</code>. The object returned is suitable for
passing to <code class="function">ne_sock_connect</code>. A binary IPv4
address contains four bytes; a binary IPv6 address contains
sixteen bytes; addresses passed must be in network byte
order.</p><p><code class="function">ne_iaddr_cmp</code> can be used to compare two
network addresses; returning zero only if they are identical. The
addresses need not be of the same address type; if the addresses
are not of the same type, the return value is guaranteed to be
non-zero.</p><p><code class="function">ne_iaddr_print</code> can be used to print the
human-readable string representation of a network address into a
buffer, for instance the string
<code class="literal">"127.0.0.1"</code>.</p><p><code class="function">ne_iaddr_typeof</code> returns the type of the
given network address.</p><p><code class="function">ne_iaddr_free</code> releases the memory
associated with a network address object.</p></div><div class="refsect1" lang="en"><a name="id2934159"></a><h2>Return value</h2><p><code class="function">ne_iaddr_make</code> returns <code class="literal">NULL</code> if the
address type passed is not supported (for instance on a platform
which does not support IPv6).</p><p><code class="function">ne_iaddr_print</code> returns the
<code class="parameter">buffer</code> pointer, and never <code class="literal">NULL</code>.</p></div><div class="refsect1" lang="en"><a name="id2934202"></a><h2>Examples</h2><p>The following example connects a socket to port 80 at the
address <code class="literal">127.0.0.1</code>.</p><pre class="programlisting">unsigned char addr[] = "\0x7f\0x00\0x00\0x01";
ne_inet_addr *ia;
ia = ne_iaddr_make(ne_iaddr_ipv4, addr);
if (ia != NULL) {
ne_socket *sock = ne_sock_connect(ia, 80);
ne_iaddr_free(ia);
/* ... */
} else {
/* ... */
}</pre></div><div class="refsect1" lang="en"><a name="id2934229"></a><h2>See also</h2><p><a href="refresolve.html#ne_addr_resolve">ne_addr_resolve</a></p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="refgetst.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="refalloc.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ne_get_status </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> ne_malloc</td></tr></table></div></body></html>