hamcast  Version 0.7
simple_receiver.cpp

This example shows how to receive multicast packets with a multicast socket.

// this header contains all needed classes and functions
// to use the HAMcast library
#include "hamcast/hamcast.hpp"
// C++ STL includes for std::cout and std::copy()
#include <iostream>
#include <algorithm>
int main()
{
// throws if no middleware was found
// join a multicast group
s.join("ip://239.0.1.1:1234");
// receive one packet
// interpret its content as C-string
const char* msg = reinterpret_cast<const char*>(mp.data());
// print the received text
std::copy(msg, msg + mp.size(), std::ostream_iterator<char>(std::cout));
std::cout << std::endl;
// done
return 0;
}