[chan available]: TIP 287 patch available

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


  1. Matt wrote (at Mon, 30 Oct 2006, 11:11):

You are awesome. Keep up the good work.

  1. Dossy Shiobara wrote (at Mon, 30 Oct 2006, 20:58):

Not to rain on your parade or anything, but how does [chan available] differ from [fconfigure channelId -queue] ?

  1. Michael A. Cleverly wrote (at Mon, 30 Oct 2006, 21:57):

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
% set sock [socket www.tcl.tk 80]
% 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 { tcl.activestate.com 80} -sockname { 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...

  1. Dossy Shiobara wrote (at Tue, 31 Oct 2006, 16:12):
$ tclsh
% info patchlevel
% fconfigure stdin -queue
0 0
% fconfigure stdout -queue
0 0
% set fd [socket www.tcl.tk 80]
% fconfigure $fd -queue
bad option "-queue": should be one of -blocking, -buffering, -buffersize, -encoding,
-eofchar, -translation, -peername, or -sockname
Hmm. I wonder why -queue is available on stdin and stdout, but not file channels returned from [socket].
  1. Michael A. Cleverly wrote (at Tue, 05 Dec 2006, 20:57):
I'm happy to note that a revised version of my tip was accepted in time to be included in Tcl 8.5.

Permanent URL for this post: http://blog.cleverly.com/permalinks/270.html