Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Is multicast supported now? #36

Open
tan-wei opened this issue Mar 27, 2020 · 3 comments
Open

Is multicast supported now? #36

tan-wei opened this issue Mar 27, 2020 · 3 comments
Labels

Comments

@tan-wei
Copy link

tan-wei commented Mar 27, 2020

After a glance of the source code, I guess not. Multicast can be supported when a flag is set.
If not, any workaround? Thanks!
BTW, #7 mentions about a platform related flag SO_REUSEPORT, which may make it hard to workaround.

@tan-wei
Copy link
Author

tan-wei commented Mar 27, 2020

As a reference, Multicast in Ruby gives us a snippet. For following is about multicast joiner:

require "socket"
require "ipaddr"

MULTICAST_ADDR = "224.0.0.1"
BIND_ADDR = "0.0.0.0"
PORT = 3000

socket = UDPSocket.new
membership = IPAddr.new(MULTICAST_ADDR).hton + IPAddr.new(BIND_ADDR).hton

socket.setsockopt(:IPPROTO_IP, :IP_ADD_MEMBERSHIP, membership)
socket.setsockopt(:SOL_SOCKET, :SO_REUSEPORT, 1)

socket.bind(BIND_ADDR, PORT)

loop do
  message, _ = socket.recvfrom(255)
  puts message
end

@ioquatix
Copy link
Member

ioquatix commented Jun 2, 2020

When I have time, I'll check it, but it should be working.

@tan-wei
Copy link
Author

tan-wei commented Jun 4, 2020

Nice. Thanks very much.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants