Levisvv Member Licensed User Longtime User May 20, 2014 #1 I have an app that makes a socket connection to a server, and leave the connection open. This works and whenever a user presses a button I can receive it just fine on the server. The only sample code I coudl find for receiving data from the server seems to be blocking: Dim tr As TextReader tr.Initialize(Socket1.InputStream) Dim sb As StringBuilder sb.Initialize sb.Append(tr.ReadLine) 'read at least one line Do While tr.Ready sb.Append(CRLF).Append(tr.ReadLine) Loop How can I Asynchronously receive the text messages from the server without need to stay in this loop? Thanks in advance..
I have an app that makes a socket connection to a server, and leave the connection open. This works and whenever a user presses a button I can receive it just fine on the server. The only sample code I coudl find for receiving data from the server seems to be blocking: Dim tr As TextReader tr.Initialize(Socket1.InputStream) Dim sb As StringBuilder sb.Initialize sb.Append(tr.ReadLine) 'read at least one line Do While tr.Ready sb.Append(CRLF).Append(tr.ReadLine) Loop How can I Asynchronously receive the text messages from the server without need to stay in this loop? Thanks in advance..
Erel B4X founder Staff member Licensed User Longtime User May 20, 2014 #2 You should use AsyncStreams to manage network communication. Upvote 0
Levisvv Member Licensed User Longtime User May 20, 2014 #3 Yes I found that and AsyncStreams works perfect thanks - I guess I just need to read a bit more next time... Upvote 0
Yes I found that and AsyncStreams works perfect thanks - I guess I just need to read a bit more next time...