roDatagramSocket
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: The local port number to bind to.
- interface integer or 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.