B4J Question B4J AsyncStreamsObject problem

Not open for further replies.


Licensed User
Longtime User
I built a client server project in B4J desktop. The server is defined as Private Server As ServerSocket from the jNetwork library. Servers and clients frequently exchange information by passing a map file. When the server has only one client connected, everything works fine. When connecting 2 or more clients start errors in AsyncStreamsObject. More clients more errors. This is a typical error in AsyncStreamsObject:

java.lang.Exception: CRC value does not match.
at anywheresoftware.b4a.randomaccessfile.AsyncStreams$AIN.run(AsyncStreams.java:253)
at java.lang.Thread.run(Thread.java:748)
astream_Error: (Exception) java.lang.Exception: CRC value does not match.

This class works using disk files named "ao" plus a progressive number. When connecting multiple clients, there are several AsyncStreamsObject instances that can use the same file name and generate an error. To solve this problem I modified AsyncStreamsObject by inserting a global string variable (Private Unique as string). At the time of Initialize, I enter the value of DateTime.Now (Unique = DateTime.now). In the GetAvailableFile function that returns the name of the work file, put the variable in front of the fixed name "ao" (Unique & "ao" & i) so as to generate a unique name for all AsyncStreamsObject instances. Errors are greatly diminished but not finished. AsyncStreamsObject uses the AsyncStreams class which in turn uses an "AsyncInput" file name plus a number with the same logic as AsyncStreamsObject. But I do not have AsyncStreams sources and I can not correct them.
Perhaps there is another solution but as far as I have tried I have not found anything.
Does anyone have the solution or a suggestion to give me?
Thank you