📄 crtchnlhdlr.3
字号:
'\"'\" Copyright (c) 1996 Sun Microsystems, Inc.'\"'\" See the file "license.terms" for information on usage and redistribution'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.'\"'\" SCCS: @(#) CrtChnlHdlr.3 1.10 96/03/14 10:54:43.so man.macros.TH Tcl_CreateChannelHandler 3 7.5 Tcl "Tcl Library Procedures".BS'\" Note: do not modify the .SH NAME line immediately below!.SH NAMETcl_CreateChannelHandler, Tcl_DeleteChannelHandler \- call a procedure when a channel becomes readable or writable.SH SYNOPSIS.nf.nf\fB#include <tcl.h>\fR.spvoid\fBTcl_CreateChannelHandler\fR(\fIchannel, mask, proc, clientData\fR).spvoid\fBTcl_DeleteChannelHandler\fR(\fIchannel, proc, clientData\fR).sp.SH ARGUMENTS.AS Tcl_ChannelProc clientData.AP Tcl_Channel channel inTcl channel such as returned by \fBTcl_CreateChannel\fR..AP int mask inConditions under which \fIproc\fR should be called: OR-ed combination of\fBTCL_READABLE\fR, \fBTCL_WRITABLE\fR and \fBTCL_EXCEPTION\fR. Specifya zero value to temporarily disable an existing handler..AP Tcl_FileProc *proc inProcedure to invoke whenever the channel indicated by \fIchannel\fR meetsthe conditions specified by \fImask\fR..AP ClientData clientData inArbitrary one-word value to pass to \fIproc\fR..BE.SH DESCRIPTION.PP\fBTcl_CreateChannelHandler\fR arranges for \fIproc\fR to be called in thefuture whenever input or output becomes possible on the channel identifiedby \fIchannel\fR, or whenever an exceptional condition exists for\fIchannel\fR. The conditions of interest under which \fIproc\fR will beinvoked are specified by the \fImask\fR argument.See the manual entry for \fBfileevent\fR for a precise description ofwhat it means for a channel to be readable or writable.\fIProc\fR must conform to the following prototype:.CStypedef void Tcl_ChannelProc( ClientData \fIclientData\fR, int \fImask\fR);.CE.PPThe \fIclientData\fR argument is the same as the value passed to\fBTcl_CreateChannelHandler\fR when the handler was created. Typically,\fIclientData\fR points to a data structure containing application-specificinformation about the channel. \fIMask\fR is an integer mask indicatingwhich of the requested conditions actually exists for the channel; it willcontain a subset of the bits from the \fImask\fR argument to\fBTcl_CreateChannelHandler\fR when the handler was created..PPEach channel handler is identified by a unique combination of \fIchannel\fR,\fIproc\fR and \fIclientData\fR.There may be many handlers for a given channel as long as they don'thave the same \fIchannel\fR, \fIproc\fR, and \fIclientData\fR.If \fBTcl_CreateChannelHandler\fR is invoked when there is already a handlerfor \fIchannel\fR, \fIproc\fR, and \fIclientData\fR, then no newhandler is created; instead, the \fImask\fR is changed for theexisting handler..PP\fBTcl_DeleteChannelHandler\fR deletes a channel handler identified by\fIchannel\fR, \fIproc\fR and \fIclientData\fR; if no such handler exists,the call has no effect..PPChannel handlers are invoked via the Tcl event mechanism, so theyare only useful in applications that are event-driven.Note also that the conditions specified in the \fImask\fR argumentto \fIproc\fR may no longer exist when \fIproc\fR is invoked: forexample, if there are two handlers for \fBTCL_READABLE\fR on the samechannel, the first handler could consume all of the available inputso that the channel is no longer readable when the second handleris invoked.For this reason it may be useful to use nonblocking I/O on channelsfor which there are event handlers..SH "SEE ALSO"Notifier(3), Tcl_CreateChannel(3), Tcl_OpenFileChannel(3), vwait(n)..SH KEYWORDSblocking, callback, channel, events, handler, nonblocking.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -