PhilipBrown Active Member Licensed User Longtime User Aug 18, 2013 #1 The documentation for InputStream member BytesAvailable says that it "returns an estimation of the number of bytes available without blocking". I am trying to clarify exactly what "without blocking" means in this context.
The documentation for InputStream member BytesAvailable says that it "returns an estimation of the number of bytes available without blocking". I am trying to clarify exactly what "without blocking" means in this context.
Erel B4X founder Staff member Licensed User Longtime User Aug 18, 2013 #2 If you call InputStream.ReadBytes on a network stream then the thread will wait for at least a single byte to be available. In most cases it will cause your app to crash. So you can check InputStream.BytesAvailable before calling ReadBytes to avoid blocking the main thread. Before AsyncStreams object was available the proper way to read data from a network stream was by checking whether there are bytes available every x milliseconds (with a timer). However AsyncStreams is much better for such tasks and should be used instead. Upvote 0
If you call InputStream.ReadBytes on a network stream then the thread will wait for at least a single byte to be available. In most cases it will cause your app to crash. So you can check InputStream.BytesAvailable before calling ReadBytes to avoid blocking the main thread. Before AsyncStreams object was available the proper way to read data from a network stream was by checking whether there are bytes available every x milliseconds (with a timer). However AsyncStreams is much better for such tasks and should be used instead.