UDP Broadcast problem

Kevin

Well-Known Member
Licensed User
Longtime User
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:

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? :confused:
 

Kevin

Well-Known Member
Licensed User
Longtime User
I think so. A competing app sends out what I believe are UDP packets. In Wireshark they appear as "Who has xxx? Tell yyy" and the receivers respond.

Is it possible to broadcast TCP packets?
 
Upvote 0

Kevin

Well-Known Member
Licensed User
Longtime User
After some more packet sniffing, I think I figured out what I need to do but I don't know how to do it...

The satellite receivers send out SSDP packets over UDP/port 1900 to the multicast address (239.255.255.250). However, I can't seem to figure out a way to capture these packets in B4A so I can use them to automatically discover the receivers on the network.

A search for SSDP on this site came up with one thread where Erel said he didn't know enough about SSDP but this was a while ago. Anyone have any ideas?
 
Upvote 0

Kevin

Well-Known Member
Licensed User
Longtime User
Yeah, I have that reflection multicast code in my app as well. Just isn't working.

Oh well.
 
Upvote 0
Top