AStream.Write(data)
Wait For AStream_NewData(buffer() As Byte)
'Work with buffer.
'if you are not using prefix mode, and I have a feeling that you aren't, then this code is broken. Better solution to call it inside a loop and collect the data with B4XBytesBuilder.