I send long value with B4J.
Send value is 1234567890
B4X:
If msg.StartsWith("#TIME#") Then
Dim Port As Int = edBroadcastPort.Text
Packet.Initialize( bc.LongsToBytes(Array As Long(1234567890)), edBroadcastHost.Text, Port)
UDPSocket1.Send(Packet)
Log("send date")
End If
I recived with B4R. But result is not same
B4X:
Sub Udp_PacketArrived (Data() As Byte, Ip() As Byte, Port As UInt)
Log("PacketArrived data:",Data)
Log("PacketArrived port:",Port)
Log("PacketArrived ip:",Ip)
Dim x As String =bc.LongsFromBytes(Data)
Log("Data:",x) 'Data:1073681064
Log("boy:",Data.Length) 'boy:8
Dim ll() As Long=bc.LongsFromBytes(Data)
Log("Data2:",ll.Length,"< - >", ll(0)) 'return ....>> Data2:2< - >0
Log("Data3:",ll.Length,"< - >", ll(1)) 'return ....>> Data2:2< - >-771582391
end if
actually , I want send datetime value beetwen B4R and B4J.
I solved .. (If you use min time value is SECOND (milisecond not support)) ' max year of 2050...
B4J >>> B4R
B4X:
'******B4J**********
Dim b() As Byte=bc.LongsToBytes(Array As Long(DateTime.Now/1000))
Dim bs(4) As Byte
bs(0)=b(7)
bs(1)=b(6)
bs(2)=b(5)
bs(3)=b(4)
Packet.Initialize( bs, edBroadcastHost.Text, Port)
UDPSocket1.Send(Packet)
B4X:
'*******B4R************
Sub Udp_PacketArrived (Data() As Byte, Ip() As Byte, Port As UInt)
Dim llu() As ULong=bc.ULongsFromBytes(Data)
Log("Date Time Value:",llu(0))
B4R >>> B4J
B4X:
*****B4R*****
UDP_Send_Packet(bc.ULongsToBytes(llu)) 'llu is long value
Public Sub UDP_Send_Packet(Message() As Byte) As Boolean
Log("port server:",wifi_server.Server_PORT)
If Socket.BeginPacket(GlobalStore.Slot2, wifi_server.Server_PORT) Then
Socket.Write(Message)
Return Socket.SendPacket
Else
Log("UDP errorı")
End If
Return False
End Sub
B4X:
************B4J**********
Sub UDP_PacketArrived (Packet As UDPPacket)
'---------------incoming data------------
Dim dd(8) As Byte
For i=0 To 3
dd(i)=0
dd(i+4)=Packet.Data(3-i)
Next
Dim xl() As Long=bc.LongsFromBytes(dd)
Log(xl(0)*1000)
Log(DateTime.Date(xl(0)*1000))
Log(DateTime.Time(xl(0)*1000))
'------------------------------------------------------------