Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Warning

...

Important

This object can receive multicast packets, but it doesn't have a way to explicitly join a multicast group. Therefore, this object is not suitable for multicast use. Use roDatagramSocket for multicast receiving. 

...

borderColor#3D3D3D
bgColor#F4F4F4
titleColor#3D3D3D
borderWidth0
titleBGColor#3D3D3D
borderStylesolid

...

Table of Contents
indent20px

This object sends roDatagramEvent instances to a message port when UDP packets are received on a specified port. The JavaScript equivalent is Node.js Dgram API.

Object Creation: The roDatagramReceiver object is created with a port parameter, which specifies the port on which to receive UDP packets.

Code Block
CreateObject("roDatagramReceiver ", port As Integer)

ifUserData

SetUserData(user_data As Object)

Sets the user data that will be returned when events are raised.

GetUserData() As Object

Returns the user data that has previously been set via SetUserData(). It will return Invalid if no data has been set.

ifIdentity

GetIdentity() As Integer

...

The ifIdentity interface has been deprecated. We recommend using the ifUserData interface instead.

ifMessagePort

SetPort(port As roMessagePort)

Posts messages of type 

...

roDatagramEvent to the attached message port.

This example script listens for UDP packets on port 21075:

Code Block
receiver = CreateObject("roDatagramReceiver", 21075)
mp = CreateObject("roMessagePort")
receiver.SetPort(mp)
while true
       event = mp.WaitMessage(0)
       if type(event) = "roDatagramEvent" then
             print "Datagram: "; event
       endif
end while

Panel
borderColor#3D3D3D
bgColor#F4F4F4
titleColor#3D3D3D
borderWidth0
titleBGColor#3D3D3D
borderStylesolid

ON THIS PAGE

Table of Contents
indent20px