?? How to subscribe to Multicast Broadcasts ??

Steven Schveighoffer schveiguy at gmail.com
Fri Aug 17 14:17:04 UTC 2018


On 8/12/18 9:12 PM, Joe wrote:
> Hello All!
> 
> I've been trying every possible combination and cannot get anything 
> working. (>_<)
> 
> This is I think the closest I've got, I think the problem may be with 
> the 3 argument.  I'm not sure how to join the Multicast IP membership?
> (this code currently does not work - throws error:
> 'Unable to set socket option: An invalid argument was supplied'.)
> 
> Socket listen_socket = new Socket(AddressFamily.INET, SocketType.DGRAM, 
> ProtocolType.UDP);
> listen_socket.setOption(SocketOptionLevel.IGMP, 
> SocketOption.IPV6_JOIN_GROUP, 1);
> auto adr = getAddress("0.0.0.0", "56000");
> listen_socket.bind(adr[0]);
> 
> 
> This is how the messages are sent (which works fine):
> 
> Socket udp_broadcast_soc = new UdpSocket();
> udp_broadcast_soc.setOption(SocketOptionLevel.SOCKET, 
> SocketOption.BROADCAST, 1);
> auto adr = getAddress("239.192.0.10", 54000);
> udp_broadcast_soc.sendTo(<message>, adr[0]);
> 
> 
> Please Please Please Help, I am desperate!
> 

This needs more context. What is your platform? Have you tried doing it 
in C to see what works?

One thing that stands out so far is you are using IPV4 addresses and 
constants everywhere, yet you are using IPV6_JOIN_GROUP socket option.

-Steve


More information about the Digitalmars-d-learn mailing list