B4J Question B4J and UDP question

Jerez

Active Member
Licensed User
Longtime User
Hi, i build an app to connect each to other using UDP protocol sending a message to 255.255.255.255 and 8888 port.

Also i have a C# Windows Service with similar code that send a response at port 8888 that works great with follow sample code (B4a)

My questions is, can i do something similiar with B4J and UDP? also use in Raspberry Pi?

I want to deprecate my C# app and go cross platform... excuse my english

thanks!

My B4a code:
B4X:
Dim Packet As UDPPacket

 
    Dim dest As String
    Dim data() As Byte
 
    UDPSocket1.Initialize("UDP", 8888, 8000)
 
    data = "REQUEST".GetBytes("UTF8")
 
    dest = "255.255.255.255"
 
    Packet.Initialize(data, dest, 8888)
 
    UDPSocket1.Send(Packet)

B4X:
Sub UDP_PacketArrived (Packet As UDPPacket)
 
     Dim ResponseMachine As String = "http://" & Packet.HostAddress & ":8083"
'Here is my server!

End Sub

EDIT***

I'm sorry this question is already answered... obviously... yes we can!

https://www.b4x.com/android/forum/threads/udp-sample.39886/#content
 
Last edited:
Top