View on GitHub

Asio Service Discovery

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

Download this project as a .zip file Download this project as a tar.gz file
betabugs::networking::service_announcer Class Reference

#include <service_announcer.hpp>

Public Member Functions

 service_announcer (boost::asio::io_service &io_service, const std::string &service_name, const unsigned short service_port, const unsigned short multicast_port=30001, const boost::asio::ip::address &multicast_address=boost::asio::ip::address::from_string("239.255.0.1"))
 

Detailed Description

class to announce a named network service, that can be discovered via the service_discoverer.

example:

boost::asio::io_service io_service;
service_announcer announcer(io_service, "my_awesome_service", 1337);
io_service.run();

Note: In case of error, this class just prints to std::cerr In case of an unknown service, this class prints it to std::clog

Constructor & Destructor Documentation

betabugs::networking::service_announcer::service_announcer ( boost::asio::io_service &  io_service,
const std::string &  service_name,
const unsigned short  service_port,
const unsigned short  multicast_port = 30001,
const boost::asio::ip::address &  multicast_address = boost::asio::ip::address::from_string("239.255.0.1") 
)
inline

announce service named service_name listening on service_port in one second intervals. Note, that it is not required, that the service actually listens on service_port and that there is no coupling between the announcer and you service.

Parameters
io_serviceio_service to use
service_namethe name of the announced service
service_portthe port where the service listens on
multicast_portthe port this udp multicast sender sends to
multicast_addressmulicast address to use. see: http://en.wikipedia.org/wiki/Multicast_address

The documentation for this class was generated from the following file: