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