{"id":6052,"date":"2022-12-20T18:57:53","date_gmt":"2022-12-20T21:57:53","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/fblocked-mann\/"},"modified":"2022-12-20T18:57:53","modified_gmt":"2022-12-20T21:57:53","slug":"fblocked-mann","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/fblocked-mann\/","title":{"rendered":"fblocked (mann)"},"content":{"rendered":"<h1 align=\"center\">fblocked<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#EXAMPLE\">EXAMPLE<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#KEYWORDS\">KEYWORDS<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">fblocked \u2212 Test whether the last input operation exhausted all available input<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>fblocked<\/b> <i>channelId<\/i><\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>fblocked<\/b> command returns 1 if the most recent input operation on <i>channelId<\/i> returned less information than requested because all available input was exhausted. For example, if <b>gets<\/b> is invoked when there are only three characters available for input and no end-of-line sequence, <b>gets<\/b> returns an empty string and a subsequent call to <b>fblocked<\/b> will return 1.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>ChannelId<\/i> must be an identifier for an open channel such as a Tcl standard channel (<b>stdin<\/b>, <b>stdout<\/b>, or <b>stderr<\/b>), the return value from an invocation of <b>open<\/b> or <b>socket<\/b>, or the result of a channel creation command provided by a Tcl extension.<\/p>\n<h2>EXAMPLE <a name=\"EXAMPLE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>fblocked<\/b> command is particularly useful when writing network servers, as it allows you to write your code in a line-by-line style without preventing the servicing of other connections. This can be seen in this simple echo-service:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"># This is called whenever a new client connects to the server proc connect {chan host port} { <br \/> set clientName [format <%s:%d> $host $port] <br \/> puts &#8220;connection from $clientName&#8221; <br \/> fconfigure $chan -blocking 0 -buffering line <br \/> fileevent $chan readable [list echoLine $chan $clientName] }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"># This is called whenever either at least one byte of input # data is available, or the channel was closed by the client. proc echoLine {chan clientName} { <br \/> gets $chan line <br \/> if {[eof $chan]} { <br \/> puts &#8220;finishing connection from $clientName&#8221; <br \/> close $chan <br \/> } elseif {![<b>fblocked<\/b> $chan]} { <br \/> # Didn\u2019t block waiting for end-of-line <br \/> puts &#8220;$clientName &#8211; $line&#8221; <br \/> puts $chan $line <br \/> } }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"># Create the server socket and enter the event-loop to wait # for incoming connections&#8230; socket -server connect 12345 vwait forever<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">gets(n), open(n), read(n), socket(n), Tcl_StandardChannels(3)<\/p>\n<h2>KEYWORDS <a name=\"KEYWORDS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">blocking, nonblocking<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  fblocked \u2212 Test whether the last input operation exhausted all available input <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3783,1],"tags":[2724,2635],"class_list":["post-6052","post","type-post","status-publish","format-standard","hentry","category-n-comandos-tcl-tk","category-sin-categoria","tag-fblocked","tag-mann"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6052","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=6052"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6052\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=6052"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=6052"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=6052"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}