Android Question AsyncStreams asynchronous sends

Rusty

Well-Known Member
Licensed User
Longtime User
I am using Prefix mode of AsyncStreams and my program sends messages to the server in various instances.
Question, if I am using the same asyncstreams, same socket etc. and my program "sends" (issues a writestream or write) at the same time (or while a large file is being sent a small message is "sent"), does this cause conflict or does AsyncStreams "queue" up the requests? Or does this "overwrite" part or all of the messages?
Thanks
Rusty
 

Rusty

Well-Known Member
Licensed User
Longtime User
Thanks Erel,
I understand it is duplex, what I was asking is, on my tablet, if I issue a send file for a large file and while the large file is sending, I issue a send of another file or message, will this cause the file(s) to fail in their transmission. Or will they be sent one at a time?
Thanks,
Rusty
 
Upvote 0

Asim A Baki

Active Member
Licensed User
Longtime User
Erel, I'm trying the AsyncStreams but the duplex mode is not active, when I'm sending a large file from the server to the client, I write the progress back to the server but what I face is all the progress messages are queued and sent back to the server at once after the complete file is transferred, is it because of the server side or the client side?
 
Upvote 0

Asim A Baki

Active Member
Licensed User
Longtime User
[Solved] Found the solution, Actually it is server side issue, the issue is solved by using THREADING at server, because the server was waiting to finish sending the file and the thread stopped there

Another simple solution is to move the receive processing after the
BeginRead statement

B4X:
               networkStream.BeginRead(client.Buffer, 0, client.Buffer.Length, AddressOf ReadCallback, client)
RaiseEvent DataAvailable(client.TcpClient.Client.RemoteEndPoint.ToString, data.Substring(4).Replace("<EOF>", ""), client.Buffer)
 
Last edited:
Upvote 0
Top