SDL_net icon indicating copy to clipboard operation
SDL_net copied to clipboard

Allow UDP broadcasts

Open captain0xff opened this issue 9 months ago • 4 comments

SDL2_net had a way to enable or disable UDP broadcasts https://github.com/libsdl-org/SDL_net/blob/8e1e4bfcb7b3ba42b778dd7af2c38264ee9561b4/src/SDLnetUDP.c#L185 it will be nice to also have them in SDL3_net.

captain0xff avatar May 03 '24 21:05 captain0xff

So the problem is broadcasts are an IPv4 subnet thing. This concept is entirely gone from IPv6, where they have something called "anycast" addresses, but it requires configuring entire groups of computers to use it...it's not like IPv4 where you just send a packet to the .255 address and things that care listen for it.

icculus avatar May 03 '24 22:05 icculus

Oh, I was not aware of this. Ig I will have to find a better solution for server discovery. Anyways, thank you for answering. You can close the issue if you want.

captain0xff avatar May 04 '24 09:05 captain0xff

So Wikipedia has this to say:

Internet Protocol version 6 (IPv6) does not implement this method of broadcast, and therefore does not define broadcast addresses. Instead, IPv6 uses multicast addressing to the all-hosts multicast group. No IPv6 protocols are defined to use the all-hosts address, though; instead, they send and receive on particular link-local multicast addresses. This results in higher efficiency because network hosts can filter traffic based on multicast address and do not need to process all broadcasts or all-hosts multicasts.

...so maybe this is doable? I'll leave this open for now until I research more.

icculus avatar May 05 '24 15:05 icculus

Found an multicast example that seems to work for me. https://gist.github.com/hostilefork/f7cae3dc33e7416f2dd25a402857b6c6

captain0xff avatar Jul 13 '24 22:07 captain0xff