This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

STM32 DNS resolving with get_host_by_name

Hello,
I'm trying to resolve a hostname address by using the function get_host_by_name() but I have a strange behavior when I call this function.

At first, I get an error DNS_ERROR_BUSY. And then I get a trace from the callback with the resolved IP address.

It's the only call to this function in the program, why the DNS client would be busy ?

Here the code of my program :

static void dns_cbfunc(u8 in_u8_event, u8 *pu8_ip)
{
  switch(in_u8_event)
  {
    case DNS_EVT_SUCCESS:
      printf("IP resolved : %d.%d.%d.%d", pu8_ip[0], pu8_ip[1], pu8_ip[2], pu8_ip[3]);
      break;
    case DNS_EVT_NONAME:
      printf("Hostname unknown");
      break;
    case DNS_EVT_TIMEOUT:
      printf("DNS resolution timeout");
      break;
    case DNS_EVT_ERROR:
      printf("Error during DNS resolution");
      break;
    default:
      break;
  }
}
u8 u8_res = get_host_by_name((u8 *)au8_hostaddr, dns_cbfunc);
switch (res)
{
  case DNS_RES_OK:
    printf("DNS resolution success");
    break;
  case DNS_ERROR_BUSY:
    printf("DNS Resolver is still busy. Request ignored.\n");
    break;
  case DNS_ERROR_LABEL:
    printf("Host name label too long or contains invalid characters.\n");
    break;
  case DNS_ERROR_NAME:
    printf("Host name too long or domain missing.\n");
    break;
  case DNS_ERROR_NOSRV:
    printf("DNS Server IP address not specified.\n");
    break;
  case DNS_ERROR_UDPSEND:
    printf("UDP send frame error.\n");
    break;
  default:
    break;
}