Giter Site home page Giter Site logo

dns_sd-resolver's Introduction

DNS_SD-Resolver

dns_sd is the name of the standard DNS service API on Apple's Darwin platform (macOS, iOS, iPadOS, tvOS, ...). It can resolve DNS names using the default DNS servers configured in the system, custom DNS servers provided by API calls, as well as via multicast DNS (mDNS or as Apple calls it "Bonjour").

UNIX DNS functions like getaddrinfo()/gethostbyname() or higher-level system APIs like CFHost or NSURLConnection all use dns_sd under the hood for name resolution. For more details on Darwin name DNS name resolution, see Apple's Resolving DNS Hostnames guide.

The advantage of using dns_sd directly is that the API is fully asynchronous, so it will never block your main thread (and you also don't have to spawn a new thread for each DNS lookup), and it is callable, so you can easily implement your own custom DNS timeout (since the default timeouts are in the range of 30 seconds to 2 minutes, which is an eternity for most users and developers) or allow the request to be canceled when no longer needed (e.g. when the user cancels the connection request).

The downside is that it is a low-level C API, has no automatic memory management, has a clumsy interface, and is not easy to use from Objective-C or Swift. That's why I wrote this wrapper. It takes care of all the memory management and thread safety issues for you, and provides an easy-to-use Obj-C interface that can also be easily used from within your Swift code.

Currently, it only supports resolving DNS names using system-configured DNS resolvers. However, methods for resolving names using custom DNS servers or via mDNS may be added in the future.

How to use it?

Just copy src/DNS_SD_Resolver.h and src/DNS_SD_Resolver.m into your project, make sure they are added to the appropriate target and start using them. DNS_SD_Resolver.h contains the complete interface, make sure to add it to your Swift bridging header if you want to use the class in Swift code. DNS_SD_Resolver.m contains all the wrapper implementation you need. The rest of the files are just for developing and testing the code.

dns_sd-resolver's People

Contributors

codingmarkus avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.