====== Poslib DNS library ====== Poslib is the C++ library for applications using the Domain Name System that is used by all Posadis tools, including the [[Posadis DNS]] server and the [[Zoneedit]] and [[Dnsquery]] tools. It consists of a library for creating client applications using DNS, and a server library for DNS servers. For documentation on the stable series of Poslib, see [[Documentation]]. For documentation on the development series, see the [[poslib:index]]. To download the latest version, go to the [[Download]] page. ===== Features and benefits ===== ^Feature ^Benefit^ |Portable |Write your program once, and build it under many Unix variants, Linux, Windows, Mac OS X and others| |Client resolver |Write programs that send DNS messages to servers, including normal queries, zone tranfers, DNS Update messages, and so on| |Resource Record handling |Read, write and interpret many different types of Resource records (over 20 types supported)| |Master file parser |Write programs that support the standard DNS master file format| |Server library |Easily write DNS server programs without having to worry about any low-level transport details| ===== Examples ===== To see Poslib at work, you can see some simple examples Poslib ships with, or take a look at the source code of real-life applications such as the Posadis DNS server or the Zoneedit tool. Allright, a quick example: #include #include int main(int argc, char **argv) { _addr addr; DnsMessage *q = NULL, *a = NULL; pos_cliresolver res; a_record ip; try { txt_to_addr(&addr, "127.0.0.1"); // server to query q = create_query("acdam.net", DNS_TYPE_A); // query message: A record for acdam.net res.query(q, a, &addr); // send query ip = get_a_record(a); // get answer record from query printf("%s has address %d.%d.%d.%d\n", // print out answer: q->questions.begin()->QNAME.tocstr(), // queried domain name ip.address[0], ip.address[1], // IP address ip.address[2], ip.address[3]); } catch (PException p) { // catch any poslib errors printf("*** Fatal error: %s\n", p.message);// print error message } } if (q) delete q; if (a) delete a; return 0; }