beautypg.com

Rodatagramsender, rodatagramreceiver (hd2000 only) – BrightSign HD2000 Object Reference Manual User Manual

Page 58

background image

roDatagramSender, roDatagramReceiver (HD2000 only)

The roDatagramSender and roDatagramReceiver classes allow for simple sending and receiving
of unicast and broadcast UDP packets.

roDatagramSender

allows UDP packets to be sent to a specified destination. It implements

ifDatagramSender

.


roDatagramSender

is created with no parameters:

 CreateObject("roDatagramSender ")

The ifDatagramSender interface provides:
 rotBOOL SetDestination(rotSTRING destination_address, rotINT32

destination_port)

o

Specify the destination IP address in dotted quad form along with the destination port. Returns

true on success.

 rotINT32 Send(rotSTRING packet)

o

Send the specified data packet as a datagram. Returns zero on success or a negative error

number on failure.


roDatagramReceiver

causes events to be sent to a message port when UDP packets are received on

the specified port. It implements ifIdentity and ifSetMessagePort.

roDatagramReceiver

is created with a single parameter:

 CreateObject("roDatagramReceiver ", rotINT32 port)

o

Specify the port on which to receive UDP packets.



Examples:

‘ This script broadcasts a single UDP packet containing “HELLO” to
‘ anyone on the network listening on port 21075.
sender = CreateObject(“roDatagramSender”)
sender.SetDestination(“255.255.255.255”, 21075)
sender.Send(“Hello”)


‘ This 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

58

This manual is related to the following products: