Using res_nquery etc

Pieter De Wit pieter at
Sun Oct 17 04:43:21 UTC 2004

Hello Guys, (again :) )

I am still trying to get the MX records for a domain. This time I hope 
to have more luck. Here is a sample program that I am trying

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <netdb.h>
#include <sys/wait.h>
#include <signal.h>
#include <poll.h>

res_state                       res;
char                            *dname;
int                             class;
int                             type;
unsigned        char            *answer;
int                             anslen;

int main (void)
        //res_ninit (res);
        dname=malloc (1024);
        answer=malloc (1024);
        sprintf (dname,"");
        printf ("Result   : %i\n",res_nsearch 
        printf ("Error    : %s (%i)\n",hstrerror (errno),errno);
        printf ("Returned : %s\n",answer);
        return 0;

Now, I would like to know why this program seg. faults on res_nsearch (I 
have tried res_nquery - same result) Again google,resolv.h yielded no 
result. I doubt if there is even a page on the net about the resolver - 
except the IBM ones ???

btw - the above code does compile 100%


Pieter De Wit

“This e-mail is sent on the Terms and Conditions that can be accessed by Clicking on this link "

More information about the bind-users mailing list