34 a.s_addr = inet_addr( group.c_str() ) ;
36 std::pair<int,int> pair = join_imp( fd , a ) ;
39 std::ostringstream ss ;
40 ss <<
"multicast join error: " << group <<
": " << G::Process::strerror(pair.second) ;
41 throw std::runtime_error( ss.str() ) ;
47 std::pair<int,int> pair = join_imp( fd , multiaddr ) ;
49 throw std::runtime_error(
"multicast join error: " + G::Process::strerror(pair.second) ) ;
52 std::pair<int,int> Gv::Multicast::join_imp( SOCKET fd ,
const in_addr & multiaddr )
55 any.s_addr = INADDR_ANY ;
57 #if GCONFIG_HAVE_IP_MREQN
59 m.imr_multiaddr = multiaddr ;
65 struct in_addr imr_multiaddr ;
66 struct in_addr imr_interface ;
69 m.imr_multiaddr = multiaddr ;
70 m.imr_interface = any ;
74 int rc = setsockopt( fd , IPPROTO_IP , IP_ADD_MEMBERSHIP , reinterpret_cast<void*>(&m) ,
sizeof(m) ) ;
76 return std::make_pair(rc,e) ;
85 throw std::runtime_error(
"multicast not implemented" ) ;
89 throw std::runtime_error(
"multicast not implemented" ) ;
static void join(SOCKET, const std::string &)
Joins the socket to the multicast group. IPv4 only. Throws on error.