if (setsockopt(fd,IPPROTO_IP,IP_ADD_MEMBERSHIP,&mreq,sizeof(mreq)) < 0) {

 

 

            usleep(200 * 1000);
                continue;

            }

 

提示: setsockopt fail, try again

此时,errno:19     --> no such device

 

这主要和当前的网络配置有关,因为多播IP地址没有加入到路由表中。

 

解决方法:把需要用到的多播地址(如本例的224.0.0.88)加入到路由表中,命令如下:

sudo route add -net 224.0.0.88 netmask 255.255.255.255 eth0

224.0.0.88:为当前使用的多播IP地址

eth0:为当前使用的有效网卡

其它辅助命令:

sudo route del -net 224.0.0.88 netmask 255.255.255.255 eth0 //把224.0.0.88从路由表中删除

route -n //查看路由表信息

 

 route add default gw 192.168.1.1 

相关文章:

  • 2021-11-30
  • 2021-11-07
  • 2022-01-17
  • 2022-12-23
  • 2022-12-23
  • 2022-02-02
  • 2021-06-11
猜你喜欢
  • 2021-04-15
  • 2022-12-23
  • 2021-07-04
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2022-01-29
相关资源
相似解决方案