Subject: Re: Simple SRV lookup?

Re: Simple SRV lookup?

From: Eric Nichols (DirWiz) <eric_at_dirwiz.com>
Date: Fri, 18 Dec 2009 15:34:03 -0500 (EST)

After digging I found the answer. Turns out Microsoft's gethostname function
is VERY messed up. I had to add -lws2_32 to the gcc command line and the
following code to initialize things in main:

#if defined (_WIN32) && ! defined (__CYGWIN__)
  WSADATA p;
  WSAStartup ((2<<8) | 2, &p);
#endif

-- 
Thanks,
Eric
On Thu, December 17, 2009 10:56 am, Eric Nichols (DirWiz) wrote:
> Hello, Just fell upon your library and am trying to run this on a mingw
> system.  The sample programs worked wonderfully however I think I'm missing
> the basic steps to perform a simple SRV query.  My sample code is below, I'm
> thinking I'm missing some init settings but don't quite understand the sample
> code.
>
> It is currently returning:
> ares_init: Misformatted domain name
>
> I can't find any reference to this error message.  Can anyone help?  Ideally
> I'm looking for a simple function to dump back a SRV record.
>
>
> #include <stdio.h>
> #include <ares.h>
> #include <string.h>
> #include <stdlib.h>
>
> int main()
> {
>    int rc;
>    ares_channel channel;
>
>    rc=ares_library_init(ARES_LIB_INIT_ALL);
>
>    if (rc != ARES_SUCCESS)
>    {
>       fprintf(stderr, "ares_library_init: %s\n", ares_strerror(rc));
>       return 1;
>    }
>
>    rc=ares_init(&channel);
>    if (rc != ARES_SUCCESS)
>    {
>       fprintf(stderr, "ares_init: %s\n", ares_strerror(rc));
>       return 1;
>    }
>
>    printf("done!\n");
>    return (EXIT_SUCCESS);
> }
> --
> Thanks,
> Eric
>
>
>
Received on 2009-12-18