Coder Social home page Coder Social logo

zeroconfx's Introduction

Zeroconf

C++11 Multicast DNS Client

Build Status

C++11 library intended to discover services and hosts on a local network using MDNS protocol.

Overview

The idea behind MDSN discovery is to allow client applications to find IP addresses of their server counterparts by sending a query to broadcast address (255.255.255.255). MDNS client and servers talk to each other by UDP, using packet format similar to generic DNS. The approach is widely used with Apple and IoT devices.

The mainstream implementations of MDNS are Avahi and Bonjour. While doing good job in most scenarios, they are not uniformly available, or might just be too heavy to bundle for the sake of one simple call.

This library comprises a cross-platform and very light MDNS client. It's implemented against both Posix sockets and Winsock using header-only approach.

Content

src/zeroconf-detail.hpp -- data structures, domain logic, networking logic src/zeroconf-util.hpp -- helpers src/zeroconf.hpp -- client interface

test -- unit tests

samples/basic_demo/main.cpp -- console demo app that sends a query and displays the answers

basic_demo

Quick Start

  1. Import library sources from src directory to the project

  2. Include zerconf.hpp and make a call to Zeroconf::Resolve. There's only a synchronous version of the API.

#include "zeroconf.hpp"

std::vector<Zeroconf::mdns_responce> result;
bool st = Zeroconf::Resolve("_http._tcp.local", /*scanTime*/ 3, &result);
  1. Access the result as follows:
result[i].peer                 // Address of the responded machine
result[i].records              // Resource records of the answer
result[i].records[j].type;     // The type of the RR
result[i].records[j].pos;      // The offset of the RR, starting with 0xC0 
result[i].records[j].len;      // Full length of the RR
result[i].records[j].name;     // Name of the node to which the record belongs
  1. In case of failure, Zeroconf::Resolve returns false and provides diagnostic output to the client's callback:
Zeroconf::SetLogCallback([](Zeroconf::LogLevel level, const std::string& message) { ... });

zeroconfx's People

Contributors

yvz avatar mre-fog avatar

Watchers

 avatar  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.