Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 297
  • Last Modified:

DNS server: res_send, EAFNOSUPPORT

This is a DNS programming question. I donnot know where I should post so I put it here. I am writing some c code to resolve the addresses of a large amount of domain names contained in a file. Part of the code is as follows:

     queryLen = res_mkquery(
                     ns_o_query,     /* regular query */
                     domain,         /* the domain to look up */
                     ns_c_in,        /* Internet type */
                     qtype,          /* Look up the specified type record */
                     (u_char *)NULL, /* always NULL */
                     0, /* length of NULL */
                     (u_char *)NULL, /* always NULL */
                     (u_char *)&query, /* buffer for the query */
                     sizeof(query)); /* size of the buffer */

    /*
     * Send the query packet. If there is no name server
     * running on the target host, res_send() returns -1
     * and errno is ECONNREFUSED. First, clear out errno.
     */
    errno = 0;
    responseLen = res_send ((u_char *)&query,/* the query */
                         queryLen, /* true length*/
                         (u_char *)&response,/*buffer */
                         sizeof(response)); /*buf size*/

  if(responseLen < 0) { /* error */

      if (errno == ECONNREFUSED) { /* no server on the host */
      (void) fprintf (stderr,
                    "There is no name server running on %s\n",
                  nsList [nsNum]);

      } else {                   /* anything else: no response */
      (void) fprintf (stderr,
                  "There was no response from %s\n",
                  nsList [nsNum]);
      }

      continue; /* nsNum for-loop */
    }

Right after the res_send() is called, the errno is set to EAFNOSUPPORT. Can anybody tell me what is the problem here? Many thanks.

Soccer
0
summer_soccer
Asked:
summer_soccer
1 Solution
 
periwinkleCommented:
Is it possible that your program is trying to use IPv6 addresses, but the machine it is querying doesn't support it?
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now