Request: ReadAvail

BlitzMax Forums/BlitzMax Programming/Request: ReadAvail

Could a ReadAvail method be added to the TStream class that returns the number of bytes of input that can be read without blocking? I think this would be useful for various things including networking and stuff.

You cannot read anything "without blocking". When you make an IO request, your current thread switches state from "Running" to "IO". The only way to do non-blocking IO is using multithreading, where you main thread remains in the running state, and the IO is handled by worker threads, with either a callback (ideally) to the main thread (.Net style) or by using messages (Java style).

Anyway to get back on track, I don't think Streams are buffered by default, so a ReadAvail wouldn't make much sense. Sockets are tho' IIRC.

Okay thanks, but I know there was a ReadAvail() function in BlitzPlus for streams that did this, how did that work then?

I wouldn't know as I don't have the source code for BlitzPlus. If I were a gambling man I would say that BlitzPlus streams are buffered.

I second the request for a ReadAvail method.