I am trying to implement multicasting using PeerPacketUDP. In the join_multicast_group method of PeerPacketUDP, it seems it doesn't support ipv4 multicast addresses, I have tried a wide range of different multicast addresses but I am getting the error on the line where join_multicast_group was called
Condition "ret!=0" is true. Returning FAILED
Below is the code
extends Node2D
func _ready() -> void:
const MULTICAST_ADDRESS = "239.255.0.55"
const MULTICAST_PORT = 35757
var discovery_socket = PacketPeerUDP.new()
var error = discovery_socket.bind(MULTICAST_PORT)
if error != OK:
discovery_socket = null
print("Failed to bind to port: %s" % error)
return
for interface in IP.get_local_interfaces():
var interface_name = interface["name"]
var addresses = interface["addresses"] as Array[String]
if addresses.any(func(a: String): return not a.contains(":")):
var join_error = discovery_socket.join_multicast_group(MULTICAST_ADDRESS, interface_name)
if join_error != OK:
print("Failed to bind to multicast on %s: %s" % [interface_name, join_error])
I have tried this on godot 4.4 and 4.5 and I am getting the same error. I would like to know if I am using the join_multicast_group method incorrectly