Rather than continue to hijack other threads I figured I'd start my own...
The other day I managed to get broadcast packets going out (as seen in Wireshark) but couldn't get anything back. I don't know what I changed but now I can't seem to get any packets out.
This is the sample code I am using:
My LAN broadcast address is 255.255.255.255.
I don't know much about UDP or broadcast. I am trying to discover satellite receivers on the network. Normally I can send the following HTTP request to them and they return with their friendly name, etc:
http://IPADDRESS:8080/info/getLocations
Currently I just send this request out to 254 addresses looking for a reply. So how can I essentially broadcast the above to all addresses on my network using a UDP broadcast? Or am I not understanding how this works at all?
The other day I managed to get broadcast packets going out (as seen in Wireshark) but couldn't get anything back. I don't know what I changed but now I can't seem to get any packets out.
This is the sample code I am using:
B4X:
Sub process_globals
Dim UDPSocket1 As UDPSocket
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
UDPSocket1.Initialize("UDP", 0, 8000)
End If
Dim Packet As UDPPacket
Dim data() As Byte
data = "Hello from Android".GetBytes("UTF8")
Packet.Initialize(data, "10.0.0.1", 5000)
UDPSocket1.Send(Packet)
End Sub
Sub UDP_PacketArrived (Packet As UDPPacket)
Dim msg As String
msg = BytesToString(Packet.Data, Packet.Offset, Packet.Length, "UTF8")
Msgbox("Message received: " & msg, "")
End Sub
My LAN broadcast address is 255.255.255.255.
I don't know much about UDP or broadcast. I am trying to discover satellite receivers on the network. Normally I can send the following HTTP request to them and they return with their friendly name, etc:
http://IPADDRESS:8080/info/getLocations
Currently I just send this request out to 254 addresses looking for a reply. So how can I essentially broadcast the above to all addresses on my network using a UDP broadcast? Or am I not understanding how this works at all?