B4J Question how share list or map betwen two b4j app in local

behnam_tr

Active Member
Licensed User
Longtime User
hi

i have two b4j app and i want to send a list or map or array as strings to other app
two app are in same pc and local

i saw and check topic udp - B4xSerializator and others

i could use udp socket and connect two app its ok but in udp can send only bytes
i attached my projects
in receiver app i cant split and get items from array

sender app
B4X:
Dim data() As Byte
    Dim conv As ByteConverter

Dim s() As String = Array As String("ali","hasan","nima","behnam")
  
    For i=0 To s.Length-1
  
    data = conv.StringToBytes(s(i),"UTF8")
    Log(data(i))
    Next

Packet.Initialize(data, "127.0.0.1", 4546 )
    'send to app2
    UDPSocket.Send(Packet)


in other app
B4X:
Sub UDP_PacketArrived (UDPsPacket As UDPPacket)
    Dim msg As String
    msg = BytesToString(UDPsPacket.Data, UDPsPacket.Offset, UDPsPacket.Length, "UTF8")
  
    Log(msg)
End Sub

always return last item
 

Attachments

  • udp apps.zip
    2.1 KB · Views: 202
Last edited:
Top