Player APIs (BrightScript & Ja...
...
Object Reference
Networking Objects

roDatagramSocket

8min
use this object to receive multicast packets and join a multicast group by calling the joinmulticastgroup() method this object both sends and receives udp packets use rodatagramsocket if you need the player to communicate using protocols such as ssdp, which only allow a server to respond to the source of a received request the javascript equivalent is node js dgram api received packets are delivered to the message port as rodatagramevent objects ifdatagramsocket getfailurereason() as string returns additional information if the bindtolocalport or sendto methods fail bindtolocalport(port as integer) as boolean binds the socket to the specified local port use this method to receive packets sent to a specific port alternatively, if you want to receive replies to sent packets (and it doesn’t matter which local port is used), pass a port number of 0, and the player will select an unused port this method returns true upon success and false upon failure getlocalport() as integer returns the local port to which the socket is bound use this method if you passed a port number of 0 to bindtolocalport and need to determine which port the player has selected sendto(destination address as string, destination port as integer, packet as object) as integer sends a single udp packet, which can be an rostring or robytearray , to the specified address and port this method returns 0 upon success and a negative error code upon failure joinmulticastgroup(address as string) as boolean joins the multicast group for the specified address on all interfaces that are currently up this method returns true upon success and false upon failure in the event of failure, getfailurereason() may provide additional information to ensure that you are joined on all network interfaces, you should register for ronetworkhotplug events and call the joinmulticastgroup() method in response to the arrival of new networks 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 ifmessageport setport(port as romessageport) posts messages of type rodatagramevent to the attached message port ifidentity getidentity() as integer the ifidentity interface has been deprecated we recommend using the ifuserdata interface instead