chan close
Closes a channel, or one direction of it.
chan close CHAN ?DIRECTION?
Description
Writes the buffered output of CHAN and closes it, and its name goes away. With DIRECTION read or write it closes only that side of a channel that has both, such as a socket.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| CHAN | channel | required | The channel. |
| DIRECTION | read or write | none | The side to close. Values: |
Returns
An empty string.
Examples
% set f [open a.txt w]
> chan close $f
> expr {$f in [chan names]}
0
% set f [open a.txt]
> chan close $f read
Errors
% set f [open a.txt]
> catch {chan close $f bogus} m
> chan close $f
> error $m
bad direction "bogus": must be read or write
-errorcode NONE
% chan close
wrong # args: should be "chan close channelId ?direction?"
-errorcode TCL WRONGARGS
Facts
- Capability
channels. A new interpreter does not have it until the host turns it on.- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.1