Android Question AsyncStreams: is there a event when writing is completed?

welu1805

Active Member
Licensed User
Longtime User
Hi all,

I connect two devises. The first is the server, the second the client. Only the server can send to the client.

If the server will stop he sends "end" to the client with AStream1.Write(buffer). The next commands immediately are Astream1.Clear and Socket1.Close.

Sometimes the client don't receive "end" because "Write" is in a background thread and the Socket1 is closed before writing is complete.

Is there an event when writing is completed? I could put Socket1.Close in this event.

Thanks for your help
Lutz
 

eurojam

Well-Known Member
Licensed User
Longtime User
I think, there is no event, but the client can send back something in his astream_NewObject Event, then the server knows, that the client has recieved the object and you close the the socket on the server in the servers astream_NewObject Event...sounds complicated, but it should work, if you allow your client to also send requests
 
Upvote 0

welu1805

Active Member
Licensed User
Longtime User
But now the same problem is on the client: If the client receives "end" he sends "end received" to the server and immediately closes the socket on the client.
Sometimes "end received" will not be sended.
 
Upvote 0

welu1805

Active Member
Licensed User
Longtime User
Thanks Erel, I started a timer after sending "end" with 3 sec. In its Tick method I close the connection.
 
Upvote 0
Top