3

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?

user4157124
  • 2,809
  • 13
  • 27
  • 42
Urmil Parikh
  • 323
  • 3
  • 11
  • Maybe this will help: http://stackoverflow.com/questions/20289986/upnp-envelopes-from-scratch-not-really-working – Bookeater Jan 07 '17 at 21:43
  • Thanks @Bookeater, but that code receives response on non-multicast address. I want to really listen to multicast packets. However, a comment there says _generally, you normally first bind to your local IP address and then add the multicast address afterwards_, but I did not find any function available to join multicast address. – Urmil Parikh Jan 08 '17 at 08:34

1 Answers1

1

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.

Johannes Overmann
  • 4,914
  • 22
  • 38
  • I agree. I cannot find any API for the 2nd step, to join multicast group. I wonder if anyone has found a solution... – Urmil Parikh Aug 22 '18 at 02:48