Android Question ASyncStreams B4A > VB6 Ent Ed Winsock Server app

RickV

Member
Licensed User
I beleive this is not enforcing prefix mode yet I receive the following exception.

<code>
...Globals

Private aStream As AsyncStreams

Sub Client_Connected (Successful As Boolean)
aStream.InitializePrefix(Client.InputStream, False, Client.OutputStream, "astream")
...
...
</code>
** Note that even though false is coded it will still trigger datareceived event after receiving 104-500 bytes of data and not consistently either.

Log
01/03/2023 00:09:07
aStream Error: (RuntimeException) java.lang.RuntimeException: Message size too large. Prefix mode can only work if both sides of the connection follow the 'prefix' protocol.

I have read a little on AsyncStreamsText however it says you can do text only.
I need some clarification on this "Text Only" bit... Char 32-127 ? or 0-255 but RAW ASCII with no encoding ????????

I am talking to an old Win2k server with a vb6 enterprise Ed Server app. I have already discovered that I have to use the following to get the correct string at the server end from b4a.
<code>
SendData(SockBuffer(0).GetBytes("ISO-8859-1"))
</code>

So the question is, Will AsyncStreamsText send ASCII 0-255 ...... 00-FFh ?
 

DonManfred

Expert
Licensed User
Longtime User
** Note that even though false is coded it will still trigger datareceived event after receiving 104-500 bytes of data and not consistently either.
Only in prefixmode you´ll get full packets.

As far as i know you should only use prefixmode if sender and receiver are both b4x apps.

In Asyncstream you should expect the data is coming in multiple events .
You have to collect them in a bytebuffer.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
As DonManfred indicates you do not get full packets when doing serial comms. This is not a B4A effect but a universal thing that often trips up people new to it. Prefix mode overcomes you having to deal with this but needs both ends to use the protocol. AsyncStreamsText does similarly but only when receiving data. It buffers the characters and passes them all to you when a line feed character is received..
So the question is, Will AsyncStreamsText send ASCII 0-255 ...... 00-FFh
Yes, although to get the characters below ASCII Space you will need to assemble them into your string with 'Chr(num)'. By default AsyncStreamsText converts the internal B4A UTF16 encoding to UTF8 byes on writing and converts the incoming bytes from UTF8 to UTF16. It looks like you will probably have to change this in Class_Globals to "ISO-8859-1"
 
Upvote 0
Top