Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 10 Next »

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. 

ON THIS PAGE

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.

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

Note

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:

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



  • No labels