.\" ** You probably do not want to edit this file directly ** .\" It was generated using the DocBook XSL Stylesheets (version 1.69.1). .\" Instead of manually editing it, you probably should edit the DocBook XML .\" source for it and then use the DocBook XSL Stylesheets to regenerate it. .TH "NE_ADDR_RESOLVE" "3" "23 May 2006" "neon 0.26.1" "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" .PP \fB#include \fR .HP 30 \fBne_sock_addr\ *\fBne_addr_resolve\fR\fR\fB(\fR\fBconst\ char\ *\fR\fB\fIhostname\fR\fR\fB, \fR\fBint\ \fR\fB\fIflags\fR\fR\fB);\fR .HP 19 \fBint\ \fBne_addr_result\fR\fR\fB(\fR\fBconst\ ne_sock_addr\ *\fR\fB\fIaddr\fR\fR\fB);\fR .HP 34 \fBconst\ ne_inet_addr\ *\fBne_addr_first\fR\fR\fB(\fR\fBne_sock_addr\ *\fR\fB\fIaddr\fR\fR\fB);\fR .HP 33 \fBconst\ ne_inet_addr\ *\fBne_addr_next\fR\fR\fB(\fR\fBne_sock_addr\ *\fR\fB\fIaddr\fR\fR\fB);\fR .HP 20 \fBchar\ *\fBne_addr_error\fR\fR\fB(\fR\fBconst\ ne_sock_addr\ *\fR\fB\fIaddr\fR\fR\fB, \fR\fBchar\ *\fR\fB\fIbuffer\fR\fR\fB, \fR\fBsize_t\ \fR\fB\fIbufsiz\fR\fR\fB);\fR .HP 21 \fBvoid\ \fBne_addr_destroy\fR\fR\fB(\fR\fBne_sock_addr\ *\fR\fB\fIaddr\fR\fR\fB);\fR .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 .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\\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); .fi .SH "SEE ALSO" .PP ne_iaddr_print