libsdl-org / SDL_net

A simple, cross-platform wrapper over TCP/IP sockets.
zlib License
187 stars 48 forks source link

Allow UDP broadcasts #97

Open captain0xff opened 2 months ago

captain0xff commented 2 months ago

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.

icculus commented 2 months ago

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.

captain0xff commented 2 months ago

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.

icculus commented 1 month ago

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.