Fix: Closed #1 (Some need to set the interface index for multicast)

master
KoynovStas 2 years ago
parent 8c600cdcef
commit ac1d256c0f

@ -41,6 +41,7 @@
#include <signal.h>
#include <getopt.h>
#include <net/if.h> //for if_nametoindex
// my headers
#include "daemon.h"
@ -340,6 +341,12 @@ void init_gsoap()
daemon_error_exit("Cant get addr for interface error: %m\n");
}
mcast.imr_ifindex = if_nametoindex(wsdd_param.if_name);
if( mcast.imr_ifindex == 0 )
{
daemon_error_exit("Cant get index for interface error: %m\n");
}
setsockopt(soap_srv->master, IPPROTO_IP, IP_MULTICAST_IF, &mcast.imr_address.s_addr, sizeof(struct in_addr));
if(setsockopt(soap_srv->master, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *)&mcast, sizeof(mcast)) != 0 )

Loading…
Cancel
Save