1NE_ADDR_RESOLVE(3)            neon API reference            NE_ADDR_RESOLVE(3)
2
3
4

NAME

6       ne_addr_resolve,     ne_addr_result,    ne_addr_first,    ne_addr_next,
7       ne_addr_error, ne_addr_destroy -  functions  to  resolve  hostnames  to
8       addresses
9

SYNOPSIS

11       #include <ne_socket.h>
12
13
14       ne_sock_addr *ne_addr_resolve (const char *hostname, int flags);
15
16       int ne_addr_result (const ne_sock_addr *addr);
17
18       const ne_inet_addr *ne_addr_first (ne_sock_addr *addr);
19
20       const ne_inet_addr *ne_addr_next (ne_sock_addr *addr);
21
22       char *ne_addr_error (const ne_sock_addr *addr, char *buffer,
23                            size_t bufsiz);
24
25       void ne_addr_destroy (ne_sock_addr *addr);
26
27

DESCRIPTION

29       The ne_addr_resolve function resolves the given hostname, returning  an
30       ne_sock_addr  object representing the address (or addresses) associated
31       with the hostname. The flags parameter is currently unused, and must be
32       passed as 0.
33
34
35       The  hostname  passed  to  ne_addr_resolve  can be a DNS hostname (e.g.
36       "www.example.com") or an IPv4 dotted quad (e.g. "192.0.34.72"); or,  on
37       systems  which support IPv6, an IPv6 hex address, which may be enclosed
38       in brackets, e.g. "[::1]".
39
40
41       To determine whether the hostname was successfully resolved, the ne_ad‐
42       dr_result  function  is  used,  which  returns non-zero if an error oc‐
43       curred. If an error did occur, the ne_addr_error function can be  used,
44       which will copy the error string into a given buffer (of size bufsiz).
45
46
47       The  functions  ne_addr_first and ne_addr_next are used to retrieve the
48       Internet addresses associated with an address  object  which  has  been
49       successfully  resolved. ne_addr_first returns the first address; ne_ad‐
50       dr_next returns the next address after the most recent call  to  ne_ad‐
51       dr_next  or  ne_addr_first, or NULL if there are no more addresses. The
52       ne_inet_addr pointer returned by  these  functions  can  be  passed  to
53       ne_sock_connect to connect a socket.
54
55
56       After  the  address  object has been used, it should be destroyed using
57       ne_addr_destroy.
58
59

RETURN VALUE

61       ne_addr_resolve returns a pointer to an address object, and never NULL.
62       ne_addr_error returns the buffer parameter .
63
64

EXAMPLES

66       The  code  below  prints  out  the set of addresses associated with the
67       hostname www.google.com.
68
69       ne_sock_addr *addr;
70       char buf[256];
71
72       addr = ne_addr_resolve("www.google.com", 0);
73       if (ne_addr_result(addr)) {
74           printf("Could not resolve www.google.com: %s\n",
75                  ne_addr_error(addr, buf, sizeof buf));
76       } else {
77           const ne_inet_addr *ia;
78           printf("www.google.com:");
79           for (ia = ne_addr_first(addr); ia != NULL; ia = ne_addr_next(addr)) {
80               printf(" %s", ne_iaddr_print(ia, buf, sizeof buf));
81           }
82           putchar('\n');
83       }
84       ne_addr_destroy(addr);
85
86
87

SEE ALSO

89       ne_iaddr_print(3)
90
91

AUTHOR

93       Joe Orton <neon@webdav.org>.
94
95
96
97neon 0.25.5                     20 January 2006             NE_ADDR_RESOLVE(3)
Impressum