Giter Club home page Giter Club logo

asio_service_discovery's Introduction

asio_service_discovery

Build Status

Components for service discovery via udp multicasting. It's using boost::asio for async networking. It's non-blocking and non-locking.

The best way to get started is having a look at the tests. Basic functionality is derived from boost::asios udp multicast example .

Read the API-Documentation

Note the max packet size for a udp packet is limited. This library supports whatever the maximum size for udp packets on the machine(s) it's running on is (~8kb on my machine). But keep that in mind, when choosing a service name. But anything below a kb will probably be allright. If you get a "Message to long" error, be sure, that you did not chose a ridiculously long service name.

requirements

  • asio_service_discovery is using boost::asio, therefore you need the boost asio headers and you need to link agains boost_system.
  • You also need a compiler that supports C++11
  • If you want to run the tests, you also need to install cmake

How it works

There are two components: service_announcer and service_discoverer.

The announcer multicasts information about the service it's announcing in one second intervals. The packet format is: service_name:computer_name:port You have to pass service_name and service_port to the service_announcer. they can be freely chosen.

The discoverer listens for incomming multicast packets that match the service_name it was configured with. It hold a set of service_discoverer::service objects. Each time a packet comes in, it is parsed and if the service name matches, a service_discoverer::service objects is constructed and added to the set. After that the optional callback is called.

a simple example

The Announcer

  boost::asio::io_service io_service;
  betabugs::networking::service_announcer announcer(io_service, "my_service", 1337);
  io_service.run();

The Discoverer

  boost::asio::io_service io_service;
  betabugs::networking::service_discoverer discoverer(io_service, "my_service",
  [](const service_discoverer::services& services){
    std::clog << "my_service is available on the following machines:" << std::endl;
    for(const auto& service : services)
    {
      std::clog << "  " << service << std::endl;
    }
  });
  io_service.run();

License

This library is Distributed under the Boost Software License, Version 1.0 .

Bugs

In case you find any bugs, please don't hesitate to contact me. Also pull-requests are highly apprechiated.

Platform support

The discovery should work on any platform, that is supported by boost::asio. It works like a charm on OSX and iOS. If you plan on using this on Linux, Android or Windows, please report you experience.

asio_service_discovery's People

Contributors

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