项目作者: berghetti

项目描述 :
resolver asynchronous dns
高级语言: C
项目地址: git://github.com/berghetti/resolver.git
创建时间: 2020-08-06T17:18:25Z
项目社区:https://github.com/berghetti/resolver

开源协议:GNU General Public License v3.0

下载


domain resolver async

resolver asynchronous dns,
immediately returns the requested ip in text form,
however in the next request for that ip the domain will be available immediately (if there is a domain for the ip),
without generating delays in the main application

Example usage

  1. #include "domain.h"
  2. // 0 use the default number of workers
  3. thpool_init(0);
  4. // input...
  5. struct sockaddr_in6 host;
  6. host.sin6_family = AF_INET6;
  7. inet_pton ( AF_INET6, ip, &host.sin6_addr );
  8. /////////////////////////////////////////////////
  9. char buff_domain[NI_MAXHOST];
  10. char buff_service[NI_MAXSERV];
  11. // return ip immediately, no dns query latency
  12. ip2domain ( ( struct sockaddr_storage * ) &host, buff_domain, NI_MAXHOST );
  13. printf ( "ip returned 1ª call - %s\n", buff_domain );
  14. // life continue (working...)
  15. sleep ( 1 );
  16. // the next query the domain will be available immediately (cache)
  17. ip2domain ( ( struct sockaddr_storage * ) &host, buff_domain, NI_MAXHOST );
  18. printf ( "domain returned 2ª call - %s\n", buff_domain );

See folder example