fblocked
NAMESYNOPSIS
DESCRIPTION
EXAMPLE
SEE ALSO
KEYWORDS
NAME
fblocked − Test whether the last input operation exhausted all available input
SYNOPSIS
fblocked channelId
DESCRIPTION
The fblocked command returns 1 if the most recent input operation on channelId returned less information than requested because all available input was exhausted. For example, if gets is invoked when there are only three characters available for input and no end-of-line sequence, gets returns an empty string and a subsequent call to fblocked will return 1.
ChannelId must be an identifier for an open channel such as a Tcl standard channel (stdin, stdout, or stderr), the return value from an invocation of open or socket, or the result of a channel creation command provided by a Tcl extension.
EXAMPLE
The fblocked 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:
# This is
called whenever a new client connects to the server proc
connect {chan host port} {
set clientName [format <%s:%d> $host $port]
puts "connection from $clientName"
fconfigure $chan -blocking 0 -buffering line
fileevent $chan readable [list echoLine $chan $clientName]
}
# 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} {
gets $chan line
if {[eof $chan]} {
puts "finishing connection from $clientName"
close $chan
} elseif {![fblocked $chan]} {
# Didn’t block waiting for end-of-line
puts "$clientName - $line"
puts $chan $line
} }
# Create the server socket and enter the event-loop to wait # for incoming connections... socket -server connect 12345 vwait forever
SEE ALSO
gets(3), open(2), read(2), socket(2), Tcl_StandardChannels(3)
KEYWORDS
blocking, nonblocking
More Linux Commands
manpages/perlnetware.1.html
perlnetware(1) - Perl for NetWare - Linux manual page.......
This file gives instructions for building Perl 5.7 and above, and also Perl modules for NetWare. Before you start, you may want to read the README file found in
manpages/Tk_NameToWindow.3.html
Tk_NameToWindow(3) - convert between names and window tokens
Each window managed by Tk has two names, a short name that identifies a window among children of the same parent, and a path name that identifies the window uni
manpages/XkbKeyNumActions.3.html
XkbKeyNumActions(3) - Computes the number of actions associa
XkbKeyNumActions.3 - A key action defines the effect key presses and releases have on the internal state of the server. For example, the expected key action ass
manpages/tkill.2.html
tkill(2) - send a signal to a thread - Linux manual page....
tgkill() sends the signal sig to the thread with the thread ID tid in the thread group tgid. (By contrast, kill(2) can be used to send a signal only to a proces
manpages/kdesu-4.1.html
kdesu-4(1) Runs a program with elevated privileges..........
KDE su is a graphical front end for the UNIX(R)su command for the K Desktop Environment. It allows you to run a program as different user by supplying the passw
manpages/Tk_PhotoGetImage.3.html
Tk_PhotoGetImage(3) - manipulate the image data stored in a
Tk_FindPhoto returns an opaque handle that is used to identify a particular photo image to the other procedures. The parameter is the name of the image, that is
manpages/mvget_wstr.3ncurses.html
mvget_wstr(3ncurses) - get an array of wide characters from
The effect of get_wstr is as though a series of calls to get_wch were made, until a newline, other end-of-line, or end-of-file condition is processed. An end-of
manpages/read_all_mibs.3.html
read_all_mibs(3) - netsnmp_mib_api functions (Man Page).....
The functions dealing with MIB modules fall into four groups - those dealing with initialisation and shutdown, with reading in and parsing MIB files, with searc
manpages/zshoptions.1.html
zshoptions(1) - zsh options (Commands - Linux man page).....
Options are primarily referred to by name. These names are case insensitive and underscores are ignored. For example, allexport is equivalent to ...............
manpages/SDL_FreeSurface.3.html
SDL_FreeSurface(3) - Frees (deletes) a SDL_Surface (ManPage)
Frees the resources used by a previously created SDL_Surface. If the surface was created using SDL_CreateRGBSurfaceFrom then the pixel data is not freed. SEE AL
manpages/cbc_crypt.3.html
cbc_crypt(3) - fast DES encryption - Linux manual page......
ecb_crypt() and cbc_crypt() implement the NBS DES (Data Encryption Standard). These routines are faster and more general purpose than crypt(3). They also are ab
manpages/gnutls_pkcs7_get_crt_count.3.html
gnutls_pkcs7_get_crt_count(3) - API function (Man Page).....
This function will return the number of certifcates in the PKCS7 or RFC2630 certificate set. RETURNS On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a n
