Thursday I authored TIP 287 which proposes adding a [chan available] command to Tcl 8.5. This command would allow programmers at the Tcl level to introspect how much input is currently buffered & available to be read on a channel.
This command would be very useful to proactively avoid a potential class of DoS attacks on network daemons implementing line-oriented protocols (such as HTTP, SMTP, etc.)
This afternoon I finished my patch to implement the proposed functionality and uploaded it to SourceForge (TCL RFE #1586860).
I expect this TIP to be totally non-controversial and hope that the TCT will vote on it (and accept it! :-) prior to the December 1st feature freeze for Tcl 8.5.
—Michael A. Cleverly
Sunday, October 29, 2006 at 14:59
You are awesome. Keep up the good work.
Not to rain on your parade or anything, but how does [chan available] differ from [fconfigure channelId -queue] ?
Dossy, I haven't encountered a version of Tcl that has an [fconfigure channelId -queue] . It isn't listed in the 8.4 or 8.5 man pages.
powerbook:~/sandbox/bin michael$ ./tclsh8.5
% info patchlevel
8.5a5
% set sock [socket www.tcl.tk 80]
sock5
% fconfigure $sock -queue
bad option "-queue": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, -translation, -peername, or -sockname
% fconfigure $sock
-blocking 1 -buffering full -buffersize 4096 -encoding utf-8 -eofchar {{} {}} -translation {auto crlf} -peername {209.17.146.136 tcl.activestate.com 80} -sockname {192.168.1.4 powerbook.home.cleverly.com 51815}I suppose you could have a custom channel driver extension that implemented a -queue option, but I'm not familiar with (or remembering) one that does...
$ tclsh % info patchlevel 8.4.12 % fconfigure stdin -queue 0 0 % fconfigure stdout -queue 0 0 % set fd [socket www.tcl.tk 80] sock5 % fconfigure $fd -queue bad option "-queue": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, -translation, -peername, or -socknameHmm. I wonder why -queue is available on stdin and stdout, but not file channels returned from [socket].
I'm happy to note that a revised version of my tip was accepted in time to be included in Tcl 8.5.