chan - Manipulate channels http://purl.org/tcl/home/man/tcl8.5/TclCmd/chan.htm '''chan''' ''option'' ?''arg arg ...''? ** See Also ** This command (introduced in Tcl 8.5) provides several operations on a channel, including many that have been available using a mix of other commands. ''Option'' indicates what to do with the channel. Any unique abbreviation for ''option'' is acceptable. The valid ''option''s are: (see complete man page; here's only notes on selected options). : '''chan''' ''action'' ?''arg arg ...''? ''Why was thing thing called 'chan' instead of 'channel'?'' [schlenk]: It's mentioned in the TIP [http://www.tcl.tk/cgi-bin/tct/tip/208.html], basically same style as [interp] for interpreter. [TIP] [http://www.tcl.tk/cgi-bin/tct/tip/208%|%208]: add `chan` ''I see. Thank you for pointing that out. Pretty lame reasoning when "channel" is much more descriptive. But I'm not the one doing all the work so I'm not complaining! '' [JYL] If you dont like chan you can do 'interp alias {} channel {} chan' [AMG]: `chan` aggregates all the commands you'll need for working with '''[chan blocked]''' ''channelId'' '''[chan close]''' ''channelId'' '''[chan configure]''' ''channelId'' ?''optionName''? ?''value''? ?''optionName value''?... '''[chan copy]''' ''inputChan outputChan'' ?''options...''? '''[chan create]''' ''mode cmdPrefix'' '''[chan eof]''' ''channelId'' '''[chan event]''' ''channelId event'' ?''script''? '''[chan flush]''' ''channelId'' '''[chan gets]''' ''channelId'' ?''varName''? '''[chan names]''' ?''globPattern''? '''[chan postevent]''' ''channelId eventSpec'' '''[chan puts]''' ?'''-nonewline'''? ?''channelId''? ''string'' '''[chan read]''' ''channelId'' ?''numChars''? '''[chan read]''' ?'''-nonewline'''? ''channelId'' '''[chan seek]''' ''channelId offset'' ?''origin''? '''[chan tell]''' ''channelId'' '''[chan truncate]''' ''channelId'' ?''length''? ---- TIP 287 proposes a [['''chan available''' ''channelId'']] command to find out how much available input is currently being buffered that could be [chan read] in. (It would make it safe to use [chan gets] with [socket]s since you could introspect and detect someone sending an excessively long line rather than running out of memory first.) See also [chan mode] for an example how to extend that [ensemble]. ---- [RS] History sometimes runs in circles... [Tcl 2.1] didn't have commands dealing with channels. [Peter da Silva] added the "stream" extension, where one could write stream fp open $filename r set x [stream fp gets] stream fp close Later, the parts of "stream" went into the core as separate commands. Still later (in 8.5), they get reunited again in [chan], which arguably makes the command set leaner, but scripts wordier... ---- [[ [Category Command] of [Tcl] 8.5 | [Category Channel] ]]