My AutoIt script should receive UDP multicast packets sent to 239.255.250.250:9131
. But it doesn't work and I see no option to specify a UDP multicast address for UDPBind()
.
UDPBind()
in below code returns error 10049
(invalid address):
UDPStartup()
UDPBind("239.255.250.250", 9131)
While 1
$msg = UDPRecv($recv, 512)
If $msg <> "" Then
ConsoleWrite($msg)
EndIf
Sleep(100)
WEnd
How to listen for UDP multicast packets?
You must not bind to the multicast address. Bind is a local operation which sets the listening interface (on Windows) and port.
To receive multicast you need to:
Bind to the IP address of the interface and port you want to receiv mutlicast on. On Windows bind to the IP address on the selected interface. On Linux bind to 0.0.0.0.
Join the multicast group using the appropriate mechanisms.