summaryrefslogtreecommitdiffstats
path: root/doc/fcopy.n
diff options
context:
space:
mode:
authorferrieux <ferrieux@users.sourceforge.net>2014-04-28 20:28:10 (GMT)
committerferrieux <ferrieux@users.sourceforge.net>2014-04-28 20:28:10 (GMT)
commit9a76d245a9dcf48449c6f147252a9be6b43abf09 (patch)
tree1d5e0d125264484c20d6b0ee8a36ba69c33c5416 /doc/fcopy.n
parent790e5adaf4cabf6c9dcaa3d109427dbe18f786ff (diff)
downloadtcl-9a76d245a9dcf48449c6f147252a9be6b43abf09.zip
tcl-9a76d245a9dcf48449c6f147252a9be6b43abf09.tar.gz
tcl-9a76d245a9dcf48449c6f147252a9be6b43abf09.tar.bz2
Clarify fcopy manpage regarding its bidirectional uses. [1350564]
Diffstat (limited to 'doc/fcopy.n')
-rw-r--r--doc/fcopy.n27
1 files changed, 24 insertions, 3 deletions
diff --git a/doc/fcopy.n b/doc/fcopy.n
index ec3d5c6..071896c 100644
--- a/doc/fcopy.n
+++ b/doc/fcopy.n
@@ -46,8 +46,11 @@ non-blocking mode; the \fBfcopy\fR command takes care of that automatically.
However, it is necessary to enter the event loop by using
the \fBvwait\fR command or by using Tk.
.PP
-You are not allowed to do other I/O operations with
-\fIinchan\fR or \fIoutchan\fR during a background \fBfcopy\fR.
+You are not allowed to do other input operations with \fIinchan\fR, or
+output operations with \fIoutchan\fR, during a background
+\fBfcopy\fR. The converse is entirely legitimate, as exhibited by the
+bidirectional fcopy example below.
+.PP
If either \fIinchan\fR or \fIoutchan\fR get closed
while the copy is in progress, the current copy is stopped
and the command callback is \fInot\fR made.
@@ -57,7 +60,7 @@ then all data already queued for \fIoutchan\fR is written out.
Note that \fIinchan\fR can become readable during a background copy.
You should turn off any \fBfileevent\fR handlers during a background
copy so those handlers do not interfere with the copy.
-Any I/O attempted by a \fBfileevent\fR handler will get a
+Any wrong-sided I/O attempted (by a \fBfileevent\fR handler or otherwise) will get a
.QW "channel busy"
error.
.PP
@@ -149,6 +152,24 @@ set total 0
-command [list CopyMore $in $out $chunk]
vwait done
.CE
+.PP
+The fourth example starts an asynchronous, bidirectional fcopy between
+two sockets. Those could also be pipes from two [open "|hal 9000" r+]
+(though their conversation would remain secret to the script, since
+all four fileevent slots are busy).
+.PP
+.CS
+set flows 2
+proc Done {dir args} {
+ global flows done
+ puts "$dir is over."
+ incr flows -1
+ if {$flows<=0} {set done 1}
+}
+\fBfcopy\fR $sok1 $sok2 -command [list Done UP]
+\fBfcopy\fR $sok2 $sok1 -command [list Done DOWN]
+vwait done
+.CE
.SH "SEE ALSO"
eof(n), fblocked(n), fconfigure(n), file(n)
.SH KEYWORDS