Re: TIP #287: Add a Commands for Determining Size of Buffered Data

Michael A. Cleverly <michael@xxxxxxxxxxxx> wrote:
Actually no.
Without having returned to the event loop (presuming there isn't an
[update] between your [gets] and [chan pending]) and without another
attempted input operation (another call to [gets] or [read]) then the data
will be buffered at the OS level, but not yet read/seen/known to Tcl.

Oh, that of course makes my comment moot.

If that were the case then [fblocked] would have always been a very
race-condition-prone bad hack too. But it isn't.

Actually, I never used [fblocked], but then I never
queried non-blocking channels for more than gets' return
value (being >=0 or not) and [eof]. I never came into
the situation of having a use for the information provided
by [fblocked], yet.

Nevertheless, I'd find a maxSize feature for [gets] much more
programmer-friendly than the solution you offered, despite
that your solution works right now, whereas the maxSize
feature would require a TIP to be written, accepted and
implemented. :-)