Advice on the lightweight resolver, lwres.

othermark atkin901 at yahoo.com
Thu Mar 9 16:25:46 UTC 2006


I was working on converting the STAF (staf.sourceforge.net) project to an 
freebsd port, and on my first attempt, I attempted to use the lightweight
resolver library because of the thread safe functions _r() that were
available.

However once I finished a straight port, I found, that lwres_gethostbyname()
always returns 61 (connection refused).   Nothing ever shows up on tcpdump
on any interface (yes, even lo0).   Of course, just changing the netdb
include and compiling without lwres works.

example of slightly modified code from the staf project:

#include <lwres/netdb.h>
#include <errno.h>
#include <stdio.h>
#define HERROR -1

int main(void)
{

    char buffer[256];
    struct hostent *host;

    if (gethostname(buffer, sizeof(buffer)) == HERROR)
    {
        fprintf(stderr,"Error getting hostname: gethostname() RC=%d\n",
errno);
        return errno;
    }

    host = gethostbyname(buffer);

    if (host == 0)
    {
        fprintf(stderr,"Error getting hostent structure: gethostbyname()
RC=%d\n",errno);
        return errno;
    }

    return 0;

}

$ gcc -o lwres-test lwres-test.c -llwres
$ ./lwres-test
Error getting hostent structure: gethostbyname() RC=61

-- 
othermark
atkin901 at nospam dot yahoo dot com
(!wired)?(coffee++):(wired);



More information about the freebsd-hackers mailing list