Android Question AStreams block size

Carlos Muniz

Member
Licensed User
Longtime User
Hi All:

I am with a small problem here. I use a VB6 server in my PC, talking with my phone, acting as a client. I use Astreams to comunicate. The messages are concateneted in a string, in the phone.
The problem:

I can send to phone blocks of 1400 bytes and nothing more, or the App crashes. How can I increase the block size to something around 10KBytes ?

Thanx in advance.
 

DonManfred

Expert
Licensed User
Longtime User
or the App crashes
With which error?

I don´t see a reason that you can not send 10kb of data or more.
Do expect them not to come in one packet though.

If it is all Text then you maybe should use AsyncstreamText.
 
Upvote 0

Carlos Muniz

Member
Licensed User
Longtime User
Thank you.

The message is a picture BASE64 string. 1400 bytes at once is ok, but the proccess become very lazzy. I'd like to increase speed sending
blocks bigger tham 1400 bytes. Reading the error message, I could see, the problem is with the bitmap charge.
The error message is:

main_auxiliar_foto (java line: 770)
java.lang.RuntimeException: Error loading bitmap.
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize2(CanvasWrapper.java:539)
at b4a.example.main._auxiliar_foto(main.java:770)
at b4a.example.main._recebeu(main.java:2637)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1083)
at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:1038)
at b4a.example.starter._astream_newdata(starter.java:201)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA$2.run(BA.java:370)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:8019)
at java.lang.reflect.Method.invoke(Native Method)
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
I can send to phone blocks of 1400 bytes and nothing more, or the App crashes. How can I increase the block size to something around 10KBytes ?
No. Astreams is typical networking, where you cannot expect data to be sent as one packet. When receiving, you have to account for this and re-assembly the packet. If you are sending text (I'm guessing here from the information of your other post [https://www.b4x.com/android/forum/threads/bitmap-initialize2-problem.121952/] that your are sending Data URLs) AND your communications is happening between B4X platforms, then just use AsyncStreamsText (https://www.b4x.com/android/forum/t...n-working-with-streams-of-text.27002/#content).

BTW, this totally explains why your bitmap code is failing (you're only getting a fragment of your bitmap). It would have been really nice if you would have explained your project better between this post on the other post.

Update: Since you're using a VB6 server to send the info, you'll have to device a means to communicate START and STOP of the message sent from the server to the client.
 
Upvote 0

Carlos Muniz

Member
Licensed User
Longtime User
The Server splits the string in several 1400 bytes blocks and sends them, one by one answering client's requests. As the string is completely sent, the VB6 send an END message closing the section.
 
Upvote 0

Carlos Muniz

Member
Licensed User
Longtime User
Each part received by the Phone is concatened in a final string.
FinalString = FinalString & ReceivedString
When I try to charge the bitmap with FinalString the error happens and crashes the app.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
The Server splits the string in several 1400 bytes blocks and sends them, one by one answering client's requests. As the string is completely sent, the VB6 send an END message closing the section.
Are you checking on the phone that you are getting 1400 bytes? Are you checking that the final FinalString is the same length as the complete string that your server was trying to send? Are you sure you’re not accidentally appending the END indicator to your FinalString? Can you post (in a text file) one of the sent and the equivalent received Data URLs?
 
Upvote 0

Carlos Muniz

Member
Licensed User
Longtime User
I gonna send it for you. But, listen, when I send 1400 bytes blocks from VB6 to Phone the whole thing works perfectly, with zero errors.
 
Upvote 0
Top