Table of Contents

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 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


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 <stdio.h>
#include <poslib/poslib.h>
int main(int argc, char **argv) {
  _addr addr;
  DnsMessage *q = NULL, *a = NULL;
  pos_cliresolver res;
  a_record ip;
  try {
    txt_to_addr(&addr, "");             // server to query
    q = create_query("", DNS_TYPE_A);   // query message: A record for
    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;
  poslib.txt · Last modified: 2004/12/30 00:00
Copyright © Meilof Veeningen, 2002-2005 - About