What is the correct way to send udp packets to multiple devices using UDP connection?
The only trick way I find out was as showed below. However it makes connection much more slower than with a single device.
And If I need to expand the connection to as many other devices I want it will make connection much more slower.
The only trick way I find out was as showed below. However it makes connection much more slower than with a single device.
And If I need to expand the connection to as many other devices I want it will make connection much more slower.
B4X:
Sub Process_Globals
Private serverIp1() As Byte = Array As Byte(192, 168, 1, 150) 'IP Cell Phone 1
Private serverIp2() As Byte = Array As Byte(192, 168, 1, 151) 'IP Cell Phone 2
Private serverIp3() As Byte = Array As Byte(192, 168, 1, 152) 'IP Cell Phone 3
End Sub
Private Sub sendPacket
'Escreve nos dispositivos os status
For i=1 To 3
If i=1 Then
udp.BeginPacket(serverIp1, serverPort)
Else If i=2 Then
udp.BeginPacket(serverIp2, serverPort)
Else If i=3 Then
udp.BeginPacket(serverIp3, serverPort)
End If
udp.Write(ser.ConvertArrayToBytes(Array ("CONNEC1",WatchDogStatus,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)))
udp.SendPacket
Next
End Sub