1 .. _example_resolve_name:
6 This basic example shows how to create a context and resolve a host address
7 (DNS record of A type).
17 ctx = unbound.ub_ctx()
18 ctx.resolvconf("/etc/resolv.conf")
20 status, result = ctx.resolve("www.google.com")
21 if status == 0 and result.havedata:
22 print "Result.data:", result.data.address_list
24 print "Resolve error:", unbound.ub_strerror(status)
26 In contrast with the C API, the source code is more compact while the
27 performance of C implementation is preserved.
28 The main advantage is that you need not take care about the deallocation and
29 allocation of context and result structures; pyUnbound module does it
30 automatically for you.
32 If only domain name is given, the :meth:`unbound.ub_ctx.resolve` looks for
33 A records in IN class.