CrtChnlHdlr.3
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:4k
- '"
- '" 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.
- '"
- '" RCS: @(#) $Id: CrtChnlHdlr.3,v 1.2 1998/09/14 18:39:46 stanton Exp $
- .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 NAME
- Tcl_CreateChannelHandler, Tcl_DeleteChannelHandler - call a procedure when a channel becomes readable or writable
- .SH SYNOPSIS
- .nf
- .nf
- fB#include <tcl.h>fR
- .sp
- void
- fBTcl_CreateChannelHandlerfR(fIchannel, mask, proc, clientDatafR)
- .sp
- void
- fBTcl_DeleteChannelHandlerfR(fIchannel, proc, clientDatafR)
- .sp
- .SH ARGUMENTS
- .AS Tcl_ChannelProc clientData
- .AP Tcl_Channel channel in
- Tcl channel such as returned by fBTcl_CreateChannelfR.
- .AP int mask in
- Conditions under which fIprocfR should be called: OR-ed combination of
- fBTCL_READABLEfR, fBTCL_WRITABLEfR and fBTCL_EXCEPTIONfR. Specify
- a zero value to temporarily disable an existing handler.
- .AP Tcl_FileProc *proc in
- Procedure to invoke whenever the channel indicated by fIchannelfR meets
- the conditions specified by fImaskfR.
- .AP ClientData clientData in
- Arbitrary one-word value to pass to fIprocfR.
- .BE
- .SH DESCRIPTION
- .PP
- fBTcl_CreateChannelHandlerfR arranges for fIprocfR to be called in the
- future whenever input or output becomes possible on the channel identified
- by fIchannelfR, or whenever an exceptional condition exists for
- fIchannelfR. The conditions of interest under which fIprocfR will be
- invoked are specified by the fImaskfR argument.
- See the manual entry for fBfileeventfR for a precise description of
- what it means for a channel to be readable or writable.
- fIProcfR must conform to the following prototype:
- .CS
- typedef void Tcl_ChannelProc(
- ClientData fIclientDatafR,
- int fImaskfR);
- .CE
- .PP
- The fIclientDatafR argument is the same as the value passed to
- fBTcl_CreateChannelHandlerfR when the handler was created. Typically,
- fIclientDatafR points to a data structure containing application-specific
- information about the channel. fIMaskfR is an integer mask indicating
- which of the requested conditions actually exists for the channel; it will
- contain a subset of the bits from the fImaskfR argument to
- fBTcl_CreateChannelHandlerfR when the handler was created.
- .PP
- Each channel handler is identified by a unique combination of fIchannelfR,
- fIprocfR and fIclientDatafR.
- There may be many handlers for a given channel as long as they don't
- have the same fIchannelfR, fIprocfR, and fIclientDatafR.
- If fBTcl_CreateChannelHandlerfR is invoked when there is already a handler
- for fIchannelfR, fIprocfR, and fIclientDatafR, then no new
- handler is created; instead, the fImaskfR is changed for the
- existing handler.
- .PP
- fBTcl_DeleteChannelHandlerfR deletes a channel handler identified by
- fIchannelfR, fIprocfR and fIclientDatafR; if no such handler exists,
- the call has no effect.
- .PP
- Channel handlers are invoked via the Tcl event mechanism, so they
- are only useful in applications that are event-driven.
- Note also that the conditions specified in the fImaskfR argument
- to fIprocfR may no longer exist when fIprocfR is invoked: for
- example, if there are two handlers for fBTCL_READABLEfR on the same
- channel, the first handler could consume all of the available input
- so that the channel is no longer readable when the second handler
- is invoked.
- For this reason it may be useful to use nonblocking I/O on channels
- for which there are event handlers.
- .SH "SEE ALSO"
- Notifier(3), Tcl_CreateChannel(3), Tcl_OpenFileChannel(3), vwait(n).
- .SH KEYWORDS
- blocking, callback, channel, events, handler, nonblocking.