{"id":7171,"date":"2022-12-20T19:35:43","date_gmt":"2022-12-20T22:35:43","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/tcl_createfilehandler-man3-2\/"},"modified":"2022-12-20T19:35:43","modified_gmt":"2022-12-20T22:35:43","slug":"tcl_createfilehandler-man3-2","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/tcl_createfilehandler-man3-2\/","title":{"rendered":"Tcl_CreateFileHandler (man3)"},"content":{"rendered":"<h1 align=\"center\">Tcl_CreateFileHandler<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#ARGUMENTS\">ARGUMENTS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#KEYWORDS\">KEYWORDS<\/a> <\/p>\n<hr>\n<p>______________________________________________________________________________<\/p>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Tcl_CreateFileHandler, Tcl_DeleteFileHandler \u2212 associate procedure callbacks with files or devices (Unix only)<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>#include <tcl.h><\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_CreateFileHandler<\/b>(<i>fd, mask, proc, clientData<\/i>)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_DeleteFileHandler<\/b>(<i>fd<\/i>)<\/p>\n<h2>ARGUMENTS <a name=\"ARGUMENTS\"><\/a> <\/h2>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"40%\">\n<p style=\"margin-top: 1em\">int <i>fd<\/i> (in)<\/p>\n<\/td>\n<td width=\"18%\"><\/td>\n<td width=\"31%\">\n<p style=\"margin-top: 1em\">Unix file descriptor for an open file or device.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"40%\">\n<p>int <i>mask<\/i> (in)<\/p>\n<\/td>\n<td width=\"18%\"><\/td>\n<td width=\"31%\">\n<p>Conditions under which <i>proc<\/i> should be called: OR-ed combination of <b>TCL_READABLE<\/b>, <b>TCL_WRITABLE<\/b>, and <b>TCL_EXCEPTION<\/b>. May be set to 0 to temporarily disable a handler.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"40%\">\n<p>Tcl_FileProc <i>*proc<\/i> (in)<\/p>\n<\/td>\n<td width=\"18%\"><\/td>\n<td width=\"31%\">\n<p>Procedure to invoke whenever the file or device indicated by <i>file<\/i> meets the conditions specified by <i>mask<\/i>.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"40%\">\n<p>ClientData <i>clientData<\/i> (in)<\/p>\n<\/td>\n<td width=\"18%\"><\/td>\n<td width=\"31%\">\n<p>Arbitrary one-word value to pass to <i>proc<\/i>.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:69%;\">______________________________________________________________________________<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_CreateFileHandler<\/b> arranges for <i>proc<\/i> to be invoked in the future whenever I\/O becomes possible on a file or an exceptional condition exists for the file. The file is indicated by <i>fd<\/i>, and the conditions of interest are indicated by <i>mask<\/i>. For example, if <i>mask<\/i> is <b>TCL_READABLE<\/b>, <i>proc<\/i> will be called when the file is readable. The callback to <i>proc<\/i> is made by <b>Tcl_DoOneEvent<\/b>, so <b>Tcl_CreateFileHandler<\/b> is only useful in programs that dispatch events through <b>Tcl_DoOneEvent<\/b> or through Tcl commands such as <b>vwait<\/b>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>Proc<\/i> should have arguments and result that match the type <b>Tcl_FileProc<\/b>:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">typedef void <b>Tcl_FileProc<\/b>( <br \/> ClientData <i>clientData<\/i>, <br \/> int <i>mask<\/i>);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>clientData<\/i> parameter to <i>proc<\/i> is a copy of the <i>clientData<\/i> argument given to <b>Tcl_CreateFileHandler<\/b> when the callback was created. Typically, <i>clientData<\/i> points to a data structure containing application-specific information about the file. <i>Mask<\/i> is an integer mask indicating which of the requested conditions actually exists for the file; it will contain a subset of the bits in the <i>mask<\/i> argument to <b>Tcl_CreateFileHandler<\/b>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">There may exist only one handler for a given file at a given time. If <b>Tcl_CreateFileHandler<\/b> is called when a handler already exists for <i>fd<\/i>, then the new callback replaces the information that was previously recorded.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_DeleteFileHandler<\/b> may be called to delete the file handler for <i>fd<\/i>; if no handler exists for the file given by <i>fd<\/i> then the procedure has no effect.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The purpose of file handlers is to enable an application to respond to events while waiting for files to become ready for I\/O. For this to work correctly, the application may need to use non-blocking I\/O operations on the files for which handlers are declared. Otherwise the application may block if it reads or writes too much data; while waiting for the I\/O to complete the application will not be able to service other events. Use <b>Tcl_SetChannelOption<\/b> with <b>\u2212blocking<\/b> to set the channel into blocking or nonblocking mode as required.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Note that these interfaces are only supported by the Unix implementation of the Tcl notifier.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">fileevent(n), Tcl_CreateTimerHandler(3), Tcl_DoWhenIdle(3)<\/p>\n<h2>KEYWORDS <a name=\"KEYWORDS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">callback, file, handler<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  Tcl_CreateFileHandler, Tcl_DeleteFileHandler \u2212 associate procedure callbacks with files or devices (Unix only) <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2536],"tags":[2538,3007,3505],"class_list":["post-7171","post","type-post","status-publish","format-standard","hentry","category-3-llamadas-de-bibliotecas","tag-2538","tag-man3","tag-tcl_deletefilehandler"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7171","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=7171"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7171\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=7171"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=7171"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=7171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}