42. Channels

Tcl provides an extremely flexible system for managing input and output based on the concept of channels. You are probably familiar with file and TCP socket channels at the Tcl level. They are two of the channel types that Tcl itself provides. The channel system was created in order to provide a flexible, extensible, cross-platform, device-independent means of dealing with input and output. The channel design takes a two-tiered approach: from Tcl, or using a high-level approach in C, all channels are used in more or less the same way. Standard operations such as puts, read, chan flush, and so forth are the same for all channels, whatever lowlevel device (files, TCP sockets, real hardware devices, etc.) implements them. Lower-level ...

Get Tcl and the Tk Toolkit, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.