learning & testing the example in https://www.b4x.com/android/forum/threads/network-asyncstreams-b4xserializator.72149/#content
, i've tried Erel's reply here 2 month back :
implementing the b4a as a server on android, and the b4j as a client on windows(desktop),
and setting both sides clocks to exact same time,
the changes to Erel's original code are :
b4a :
and :
b4j :
i've taken the times for that 3.8mb file transfer about 30 times.
all times were between 40-65 seconds, which is very SLOW (less then 100k/sec).
my network is fast and nothing heavy was occupying it.
is that the best i can get, or am i missing something ?
Thank you
, i've tried Erel's reply here 2 month back :
Read the file into an array of bytes and send the bytes:
implementing the b4a as a server on android, and the b4j as a client on windows(desktop),
and setting both sides clocks to exact same time,
the changes to Erel's original code are :
b4a :
B4X:
Sub btnSend_Click
Dim mm As MyMessage
Dim out As OutputStream
mm.Initialize
mm.Age = edtAge.Text
mm.Name = edtName.Text
'convert the bitmap to bytes
'replace the 4 folowing lines
'out.InitializeToBytesArray(0)
'cvs.Bitmap.WriteToStream(out, 100, "PNG")
'out.Close
'mm.Image = out.ToBytesArray
'with the folowing 8 lines
Dim sharedDir As String
Dim fileName As String
Dim bAR () As Byte
sharedDir=File.DirRootExternal & "/tmp"
fileName="testo.mp3"
bAR=Bit.InputStreamToBytes(File.OpenInput(sharedDir, fileName))
mm.Image=bAR
mm.Name="3.8 MB file test"
'end replace-with
CallSub2(Starter, "SendData", ser.ConvertObjectToBytes(mm))
End Sub
and :
B4X:
Public Sub SendData (data() As Byte)
'new code
Log(DateTime.Time(DateTime.Now))
'end new code
If connected Then astream.Write(data)
End Sub
b4j :
B4X:
Sub AStream_NewData (Buffer() As Byte)
Dim mm As MyMessage
Dim in As InputStream
Dim bmp As Image
'new code
Log(DateTime.Time(DateTime.Now))
'end new
mm= ser.ConvertBytesToObject(Buffer)
edtAge.Text = mm.Age
edtName.Text = mm.Name
'convert the array of bytes to image
'delete the folowing 3 lines
'in.InitializeFromBytesArray(mm.Image, 0, mm.Image.Length)
'bmp.Initialize2(in)
'draw the image
'cvs.DrawImage(bmp, 0, 0, cvs.Width, cvs.Height)
'end delete
End Sub
i've taken the times for that 3.8mb file transfer about 30 times.
all times were between 40-65 seconds, which is very SLOW (less then 100k/sec).
my network is fast and nothing heavy was occupying it.
is that the best i can get, or am i missing something ?
Thank you