## page was copied from DnsTemplate ##master-page:HelpTemplate === watchA === <> <> https://docs.oracle.com/cd/E36784_01/html/E36873/libresolv-3lib.html https://docs.oracle.com/cd/E36784_01/html/E36875/resolver-3resolv.html#REFMAN3Bresolver-3resolv {{{ libresolv(3LIB) Name libresolv - resolver library Synopsis cc [ flag... ] file... –lresolv –lsocket –lnsl [ library... ] #include #include #include #include #include }}} == example == {{{ #include #include int main(int argc, char **argv) { int len; struct __res_state statp; union msg { uchar_t buf[NS_MAXMSG]; HEADER h; } resbuf; /* Initialize resolver */ memset(&statp, 0, sizeof(statp)); if (res_ninit(&statp) < 0) { fprintf(stderr, "Can't initialize statp.\n"); return (1); } /* * Turning on DEBUG mode keeps this example simple, * without need to output anything. */ statp.options |= RES_DEBUG; /* Search for A type records */ len = res_nsearch(&statp, "example.com", C_IN, T_A, resbuf.buf, NS_MAXMSG); if (len < 0) { fprintf(stderr, "Error occured during search.\n"); return (1); } if (len > NS_MAXMSG) { fprintf(stderr, "The buffer is too small.\n"); return (1); } /* ... Process the received answer ... */ /* Cleanup */ res_ndestroy(&statp); return (0); } }}} ---- CategoryDns CategoryWatch CategoryTemplate