Skip to content

Latest commit

 

History

History
54 lines (44 loc) · 1.17 KB

README.md

File metadata and controls

54 lines (44 loc) · 1.17 KB

async_dns_resolver

async_dns_resolver is c++ cross-platform async dns resolve library which provides simple API and designs for
high performace and high concurrency scene.Also runtime and thread safe.

Quick Start

#include <iostream>
#include "dns_resolve/dns_resolve.h"

int main(int argc,char**argv)
{
  dnsresolve::Resolver resolver;
  resolver.AsyncResolve("www.google.com", [&](const dnsresolve::Result& result) -> void {
    if (result.HasError()) {
      std::cout <<result.Error() << std::endl;
    } else {
      std::cout <<result.Name() << std::endl;
      for (const auto& v : result) {
        std::cout << v << std::endl;
      }
    }
  });
  resolver.Run();
}

Include

CMake

It is recommend to use CMake to include this library.

  1. Initialize git submodule,run
git submodule update --init
  1. (Optional) Use Cmake to build this library.
mkdir -p build && cd build && cmake .. && make

for windows user,use Visual Studio to compile static library.

  1. Include to your CMakeLists.txt
add_subdirectory(/path/to/async_dns_resolver)

target_link_libraries(your_project
    PRIVATE
        ...
        dns_resolve::lib
    )