Player APIs (BrightScript & Ja...
...
Networking Objects
roDatagramSocket
9 min
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 dynamic) as boolean prepares to accept incoming udp packets on the specified port passing an integer to this method will specify a standard port number this method can also accept an associative array to provide more control over the binding the associative array must contain the port but can also contain the interface name this method returns true upon success and false upon failure port integer integer the local port number to bind to interface integer integer or string string either the name of a network interface as a string (such as "eth0" or "wlan0") or the integer associated with the network interface index 1 any (this is the default value) 0 ethernet 1 wifi 2 modem 32767 loopback (i e packets will only be received from within the player itself) 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