Error “No such device” in call setsockopt when joining multicast group

前端 未结 2 1357
既然无缘
既然无缘 2020-12-31 08:35

I have a code in which send multicast datagrams. A critical piece of code:

uint32_t port;
int sockfd, err_ip;
const uint32_t sizebuff = 65535 - (20 + 8);
uns         


        
2条回答
  •  伪装坚强ぢ
    2020-12-31 08:50

    IP_ADD_MEMBERSHIP and bind() are only required for receiving multicast, use IP_MULTICAST_IF instead for effectively a "send-only membership" of a multicast group.

    IP_MULTICAST_IF sets the kernel to send multicast packets for a given group on a given interface, it is effectively "send-only" as you will not be able to receive traffic on that group after setting. This varies by platform: Posix platforms generally function this way as an optimisation, whilst Win32 will perform software level routing to propagate locally generated packets.

提交回复
热议问题