Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/doc/CrtChnlHdlr.3 @ 43

Last change on this file since 43 was 25, checked in by landauf, 16 years ago

added tcl to libs

File size: 3.7 KB
Line 
1'\"
2'\" Copyright (c) 1996 Sun Microsystems, Inc.
3'\"
4'\" See the file "license.terms" for information on usage and redistribution
5'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
6'\"
7'\" RCS: @(#) $Id: CrtChnlHdlr.3,v 1.6 2007/12/13 15:22:30 dgp Exp $
8.so man.macros
9.TH Tcl_CreateChannelHandler 3 7.5 Tcl "Tcl Library Procedures"
10.BS
11'\" Note:  do not modify the .SH NAME line immediately below!
12.SH NAME
13Tcl_CreateChannelHandler, Tcl_DeleteChannelHandler \- call a procedure when a channel becomes readable or writable
14.SH SYNOPSIS
15.nf
16.nf
17\fB#include <tcl.h>\fR
18.sp
19void
20\fBTcl_CreateChannelHandler\fR(\fIchannel, mask, proc, clientData\fR)
21.sp
22void
23\fBTcl_DeleteChannelHandler\fR(\fIchannel, proc, clientData\fR)
24.sp
25.SH ARGUMENTS
26.AS Tcl_ChannelProc clientData
27.AP Tcl_Channel channel in
28Tcl channel such as returned by \fBTcl_CreateChannel\fR.
29.AP int mask in
30Conditions under which \fIproc\fR should be called: OR-ed combination of
31\fBTCL_READABLE\fR, \fBTCL_WRITABLE\fR and \fBTCL_EXCEPTION\fR. Specify
32a zero value to temporarily disable an existing handler.
33.AP Tcl_FileProc *proc in
34Procedure to invoke whenever the channel indicated by \fIchannel\fR meets
35the conditions specified by \fImask\fR.
36.AP ClientData clientData in
37Arbitrary one-word value to pass to \fIproc\fR.
38.BE
39
40.SH DESCRIPTION
41.PP
42\fBTcl_CreateChannelHandler\fR arranges for \fIproc\fR to be called in the
43future whenever input or output becomes possible on the channel identified
44by \fIchannel\fR, or whenever an exceptional condition exists for
45\fIchannel\fR. The conditions of interest under which \fIproc\fR will be
46invoked are specified by the \fImask\fR argument.
47See the manual entry for \fBfileevent\fR for a precise description of
48what it means for a channel to be readable or writable.
49\fIProc\fR must conform to the following prototype:
50.CS
51typedef void Tcl_ChannelProc(
52        ClientData \fIclientData\fR,
53        int \fImask\fR);
54.CE
55.PP
56The \fIclientData\fR argument is the same as the value passed to
57\fBTcl_CreateChannelHandler\fR when the handler was created. Typically,
58\fIclientData\fR points to a data structure containing application-specific
59information about the channel. \fIMask\fR is an integer mask indicating
60which of the requested conditions actually exists for the channel; it will
61contain a subset of the bits from the \fImask\fR argument to
62\fBTcl_CreateChannelHandler\fR when the handler was created.
63.PP
64Each channel handler is identified by a unique combination of \fIchannel\fR,
65\fIproc\fR and \fIclientData\fR.
66There may be many handlers for a given channel as long as they do not
67have the same \fIchannel\fR, \fIproc\fR, and \fIclientData\fR.
68If \fBTcl_CreateChannelHandler\fR is invoked when there is already a handler
69for \fIchannel\fR, \fIproc\fR, and \fIclientData\fR, then no new
70handler is created;  instead, the \fImask\fR is changed for the
71existing handler.
72.PP
73\fBTcl_DeleteChannelHandler\fR deletes a channel handler identified by
74\fIchannel\fR, \fIproc\fR and \fIclientData\fR; if no such handler exists,
75the call has no effect.
76.PP
77Channel handlers are invoked via the Tcl event mechanism, so they
78are only useful in applications that are event-driven.
79Note also that the conditions specified in the \fImask\fR argument
80to \fIproc\fR may no longer exist when \fIproc\fR is invoked:  for
81example, if there are two handlers for \fBTCL_READABLE\fR on the same
82channel, the first handler could consume all of the available input
83so that the channel is no longer readable when the second handler
84is invoked.
85For this reason it may be useful to use nonblocking I/O on channels
86for which there are event handlers.
87
88.SH "SEE ALSO"
89Notifier(3), Tcl_CreateChannel(3), Tcl_OpenFileChannel(3), vwait(n).
90
91.SH KEYWORDS
92blocking, callback, channel, events, handler, nonblocking.
Note: See TracBrowser for help on using the repository browser.