Fix compilation with old g++ 3.3.5 and debian-sarge.
[wvstreams.git] / Docs / sgmlmanual / egfiles / wvresolverex.cc
blobdaecac81a442aefbd70ede5a6c244ce35247af1f
1 /*
2 * A WvResolver example.
4 * Tries to look up two host names given on the command line.
5 * The expected output:
6 * resolver<Err>: 1 not in DNS.
7 * resolver<Err>: 2 not in DNS.
8 * resolver<Err>: 1 not in DNS.
9 * resolver<Err>: 2 not in DNS.
10 * resolver<Err>: 1 not in DNS.
11 * resolver<Err>: 2 not in DNS.
15 #include "wvresolver.h"
16 #include "wvlog.h"
18 void test(WvResolver &dns, int argc, char **argv)
20 WvLog log("resolver", WvLog::Info);
21 const WvIPAddr *addr;
22 int res1, res2;
24 res1 = res2 = -1;
26 while (res1 < 0 || res2 < 0)
28 if (res1 < 0)
30 res1 = dns.findaddr(100, argc > 1 ? argv[1] : "abyss.cnss.ca",
31 &addr);
32 if (res1 > 0)
33 log.print("Found address for 1: %s\n", (WvString)(*addr));
34 else if (res1 < 0)
35 log.print("[1] ");
36 else
37 log(WvLog::Error, "1 not in DNS.\n");
40 if (res2 < 0)
42 res2 = dns.findaddr(100, argc > 2 ? argv[2] : "frank.foxnet.net",
43 &addr);
44 if (res2 > 0)
45 log.print("Found address for 2: %s\n", (WvString)(*addr));
46 else if (res2 < 0)
47 log.print("[2] ");
48 else
49 log(WvLog::Error, "2 not in DNS.\n");
55 int main(int argc, char **argv)
58 WvResolver dns;
59 test(dns, argc, argv);
60 test(dns, argc, argv);
64 WvResolver dns;
65 test(dns, argc, argv);
68 return 0;