Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Introspect channels by type

Open455867ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 8 years ago
Descriptionplain2001-08-27 19:22:54
The Tcl command [file channels $pattern] returns
a list of the names of all open channels, where
the name matches $pattern.

However, the names of channels are not documented
to have any particular properties.  They are just
tokens to be passed around by commands that
manipulate or use channels.

Also, any channel that happens to be aliased
to a standard channel becomes known by the
std channel name (f.e. stdout) in the
[file channels] output, not matter what its
original names was.

So. [file channels sock*] is not a foolproof
way to get a list of all open sockets.

We need another means to introspect channels
by their Tcl_ChannelType.
dgpplain2001-08-28 02:23:41
Logged In: YES 
user_id=80530

See also Tcl bug 419685
andreas_kupries Ticket [455867ffff]: 1 change [History diff]2001-09-15 06:54:33
andreas_kupriesplain2001-09-20 06:33:46
Logged In: YES 
user_id=75003

A possible interface would be:

1) [file channeltypes] returns a list of registered channel 
types, aka channel drivers.

2) [file channels -type typename] lists all channels having 
the given type.
vincentdarleyplain2001-09-20 22:27:31
Logged In: YES 
user_id=32170

This might be a good occasion to NOT extend file, but add 
a 'channel' command to Tcl:

channel types
channel names (-type typename) pat
etc.

In the future this could be extended with 'channel 
transform'.  I don't think further overloading of 'file' is 
the right place for this stuff (but I'm v. happy to hear 
arguments to the contrary).
andreas_kupriesplain2001-09-21 01:33:37
Logged In: YES 
user_id=75003

I will not argue against this. I am still wondering
how we wound up with [file channels]. Unfortunately it is 
already in 8.3.3 and not in one the 8.4 alphas or I would 
change that to [channel names] in a jiffy.
dgpplain2007-09-06 05:22:32
Logged In: YES 
user_id=80530
Originator: YES


It appears the new [chan names]
in Tcl 8.5 is just another name
for [file channels] which still
just does glob matching on the
channel name.  Introspection on
the name of the channel type is
still missing.
andreas_kupriesplain2007-09-06 05:23:51
Logged In: YES 
user_id=75003
Originator: NO

In 8.5 the command 'chan names' implements the same functionality. Internally mapped to '::file channels'.
andreas_kupriesplain2007-09-06 05:24:45
Logged In: YES 
user_id=75003
Originator: NO

Oh, by type. Yes, that we do not have anywhere.
dgpplain2019-06-03 16:07:43
See TIP 411
Log in (anonymous is fine) to add a comment.