dp_filehandler sockId ?mode command? dp_isready sockId dp_update ?idletasks? dp_after ms ?arg1 arg2 arg3 ...? dp_whenidle command ?arg1 arg2 arg3 ...? dp_waitvariable variable
if [lindex [dp_isready file3] 1] {MyOutput file3}calls MyOutput if file3 is writeable.
The dp_update command is equivalent to the Tk "update" command, except that it operates even if a connection to the X server is not present. See the Tk documentation on "update" for an expla- nation of it's usage.
The dp_after command is equivalent to the Tk "after" command, ex- cept that it operates even if a connection to the X server is not present. See the Tk documentation on "after" for an explanation of it's usage.
The dp_whenidle command arranges for the specified Tcl/Tk command to be evaluated whenever the system is about to go to sleep wait- ing for an event to occur.
The dp_waitvariable command is equivalent to the Tk "tkwait vari- able" command, except that it operates even if a connection to the X server is not present. See the Tk documentation on "tkwait" for an explanation of it's usage.
The dp_filehander command allows one to specify a Tcl/Tk command which will be evaluated whenever the file descriptor represented by sockId is readable, writable, and/or has an exceptional condi- tion pending. Command will be invoked with two arguments append- ed: a single character indicating the mode ('r', 'w', or 'e'), and the sockId.
A sockId is an identifier which represents a file descriptor. It is identical to the identifier manipulated by the Tcl-DP (Tcl Distributed Programming) network connection management commands (dp_connect, dp_shutdown, etc.). SockId's are also manipulated by the read, eof, gets, puts, and close file management commands of Tcl.
The mode argument indicates the situations when the command will be evaluated. It may be any combination of the following values:
The following file handlers create a telnet like interface to the sendmail process (the smtp port) running on the local host. The command "say" sends the string passed to it to sendmail. The re- ply is automatically printed on stdout by the get_remote pro- cedure.
proc get_remote {mode fid} { # Exit if remote connection closed on us. if {[gets $fid input] == -1} { puts stdout "Connection closed by foreign host." exit } puts stdout $input } proc say {args} { global remote puts $remote $args; } set remote [lindex [dp_connect localhost smtp] 0] dp_filehandler $remote r get_remote