.\" Title: ne_addr_resolve
.\" Author:
.\" Generator: DocBook XSL Stylesheets v1.72.0
.\" Date: 14 July 2007
.\" Manual: neon API reference
.\" Source: neon 0.26.4
.\"
.TH "NE_ADDR_RESOLVE" "3" "14 July 2007" "neon 0.26.4" "neon API reference"
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.SH "NAME"
ne_addr_resolve, ne_addr_result, ne_addr_first, ne_addr_next, ne_addr_error, ne_addr_destroy \- functions to resolve hostnames to addresses
.SH "SYNOPSIS"
.sp
.ft B
.nf
#include
.fi
.ft
.HP 30
.BI "ne_sock_addr *ne_addr_resolve(const\ char\ *" "hostname" ", int\ " "flags" ");"
.HP 19
.BI "int ne_addr_result(const\ ne_sock_addr\ *" "addr" ");"
.HP 34
.BI "const ne_inet_addr *ne_addr_first(ne_sock_addr\ *" "addr" ");"
.HP 33
.BI "const ne_inet_addr *ne_addr_next(ne_sock_addr\ *" "addr" ");"
.HP 20
.BI "char *ne_addr_error(const\ ne_sock_addr\ *" "addr" ", char\ *" "buffer" ", size_t\ " "bufsiz" ");"
.HP 21
.BI "void ne_addr_destroy(ne_sock_addr\ *" "addr" ");"
.SH "DESCRIPTION"
.PP
The
\fBne_addr_resolve\fR
function resolves the given
\fIhostname\fR, returning an
\fBne_sock_addr\fR
object representing the address (or addresses) associated with the hostname. The
\fIflags\fR
parameter is currently unused, and must be passed as 0.
.PP
The
\fIhostname\fR
passed to
\fBne_addr_resolve\fR
can be a DNS hostname (e.g.
"www.example.com") or an IPv4 dotted quad (e.g.
"192.0.34.72"); or, on systems which support IPv6, an IPv6 hex address, which may be enclosed in brackets, e.g.
"[::1]".
.PP
To determine whether the hostname was successfully resolved, the
\fBne_addr_result\fR
function is used, which returns non\-zero if an error occurred. If an error did occur, the
\fBne_addr_error\fR
function can be used, which will copy the error string into a given
\fIbuffer\fR
(of size
\fIbufsiz\fR).
.PP
The functions
\fBne_addr_first\fR
and
\fBne_addr_next\fR
are used to retrieve the Internet addresses associated with an address object which has been successfully resolved.
\fBne_addr_first\fR
returns the first address;
\fBne_addr_next\fR
returns the next address after the most recent call to
\fBne_addr_next\fR
or
\fBne_addr_first\fR, or
NULL
if there are no more addresses. The
\fBne_inet_addr\fR
pointer returned by these functions can be passed to
\fBne_sock_connect\fR
to connect a socket.
.PP
After the address object has been used, it should be destroyed using
\fBne_addr_destroy\fR.
.SH "RETURN VALUE"
.PP
\fBne_addr_resolve\fR
returns a pointer to an address object, and never
NULL.
\fBne_addr_error\fR
returns the
\fIbuffer\fR
parameter .
.SH "EXAMPLES"
.PP
The code below prints out the set of addresses associated with the hostname
www.google.com.
.sp
.RS 4
.nf
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\en",
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('\en');
}
ne_addr_destroy(addr);
.fi
.RE
.SH "SEE ALSO"
.PP
ne_iaddr_print
.SH "AUTHOR"
.PP
\fBJoe Orton\fR <\&neon@webdav.org\&>
.sp -1n
.IP "" 4
Author.
.SH "COPYRIGHT"