## Tcl8.6.17/Tk8.6.17 Documentation > Tcl Commands > fblocked

### Tcl/Tk Applications | Tcl Commands | Tk Commands | [incr Tcl] Package Commands | SQLite3 Package Commands | TDBC Package Commands | tdbc::mysql Package Commands | tdbc::odbc Package Commands | tdbc::postgres Package Commands | tdbc::sqlite3 Package Commands | Thread Package Commands | Tcl C API | Tk C API | [incr Tcl] Package C API | TDBC Package C API

### NAME

fblocked — 最新の入力操作が利用可能な全ての入力を使い果したかどうか試験する Test whether the last input operation exhausted all available input

### 構文 SYNOPSIS

fblocked channelId

### 説明 DESCRIPTION

利用可能な全ての入力が使い果たされていた為に､channelId 上への最も最近の入力操作が要求されたよりも少ない情報しか返さなかった場合この fblocked 命令は 1 を返す｡譬えば､入力用に利用可能な文字が三つだけで､行末記号が無いときに gets が起動されると､ gets は空文字を返す､そこで､引続いて fblocked を呼ぶと１を返す｡ 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 は､Tcl 標準通信路(stdin か stdout か stderr)､又は､ open や socket の起動からの返り値､又は､Tcl 拡張によってもたらされた命令が作成した通信路の返り値､の様な開かれた通信路の為の識別子でなければならない｡ 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

その他の接続への業務を妨げることなく､行毎の方式で算譜を書くことができるので､ fblocked 命令は､電網集中機能を書くには特に有用である｡呼び掛けに答えるだけの業務の簡単な例を見てみる: 　　　 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, open, read, socket, Tcl_StandardChannels

### KEYWORDS

blocking, nonblocking
Copyright © 1996 Sun Microsystems, Inc.