summaryrefslogtreecommitdiffstats
path: root/doc/fileevent.n
diff options
context:
space:
mode:
Diffstat (limited to 'doc/fileevent.n')
-rw-r--r--doc/fileevent.n9
1 files changed, 5 insertions, 4 deletions
diff --git a/doc/fileevent.n b/doc/fileevent.n
index ba35bdf..05d68f3 100644
--- a/doc/fileevent.n
+++ b/doc/fileevent.n
@@ -6,7 +6,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: fileevent.n,v 1.14 2008/06/24 14:42:51 patthoyts Exp $
+'\" RCS: @(#) $Id: fileevent.n,v 1.15 2008/10/15 10:43:37 dkf Exp $
'\"
.so man.macros
.TH fileevent n 7.5 Tcl "Tcl Built-In Commands"
@@ -107,12 +107,14 @@ In addition, the file event handler is deleted if it ever returns
an error; this is done in order to prevent infinite loops due to
buggy handlers.
.SH EXAMPLE
+.PP
In this setup \fBGetData\fR will be called with the channel as an
argument whenever $chan becomes readable. The \fBread\fR call will
read whatever binary data is currently available without blocking.
Here the channel has the fileevent removed when an end of file
occurs to avoid being continually called (see above). Alternatively
the channel may be closed on this condition.
+.PP
.CS
proc GetData {chan} {
set data [read $chan]
@@ -125,8 +127,10 @@ proc GetData {chan} {
fconfigure $chan -blocking 0 -encoding binary
fileevent $chan readable [list GetData $chan]
.CE
+.PP
The next example demonstrates use of \fBgets\fR to read line-oriented
data.
+.PP
.CS
proc GetData {chan} {
if {[gets $chan line] >= 0} {
@@ -140,15 +144,12 @@ proc GetData {chan} {
fconfigure $chan -blocking 0 -buffering line -translation crlf
fileevent $chan readable [list GetData $chan]
.CE
-
.SH CREDITS
.PP
\fBfileevent\fR is based on the \fBaddinput\fR command created
by Mark Diekhans.
-
.SH "SEE ALSO"
fconfigure(n), gets(n), interp(n), puts(n), read(n), Tcl_StandardChannels(3)
-
.SH KEYWORDS
asynchronous I/O, blocking, channel, event handler, nonblocking, readable,
script, writable.