Thread overview | |||||
---|---|---|---|---|---|
|
August 13, 2018 ?? How to subscribe to Multicast Broadcasts ?? | ||||
---|---|---|---|---|
| ||||
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! Many Thanks in Advance for your time & attention, -joe |
August 17, 2018 Re: ?? How to subscribe to Multicast Broadcasts ?? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Joe | 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
|
August 18, 2018 Re: ?? How to subscribe to Multicast Broadcasts ?? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Joe | On Monday, 13 August 2018 at 01:12:16 UTC, Joe wrote: > Please Please Please Help, I am desperate! > > Many Thanks in Advance for your time & attention, > -joe I implemented multicast support in vibe.d, I hope looking at the source can help you: https://github.com/vibe-d/vibe.d/blob/master/core/vibe/core/drivers/libevent2.d#L1129 Also, shouldn't both sending and receiving ports be the same? Where I use it I call addMembership and then canBroadcast on a vibed socket, and it has worked for me. It wouldn't be difficult to port that back to std.socket. |
Copyright © 1999-2021 by the D Language Foundation